akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, M;

bool check(int n) {
   int a = M - (n * (N-1));
   if (a > 0 && a % n == 0) {
      return true;
   }
   return false;
}

int gcd(int a, int b) {
   if (b == 0) return a;
   return gcd(b, a%b);
}

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

   int ans = 1;
   for (int i = 1; i*i <= M; i++) {
      if (M % i != 0) continue;
      int j = M / i;
      if (check(i)) {
         ans = max(ans, i);
      }
      if (check(j)) {
         ans = max(ans, j);
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
//#define cin fin
//#define cout fout
using namespace std;

//ifstream fin("file.in");
//ofstream fout("file.out");

const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

int n,m,ans;
pair<int,int>a[100005];
vector<int>acc[100005];
multiset<int>st;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(int i=1;i<=n;i++){
        cin >> a[i].fr >> a[i].sc;
        acc[a[i].fr].push_back(a[i].sc);
	}
	for(int i=m-1;i>=0;i--){
        for(int j=0;j<acc[m-i].size();j++) st.insert(acc[m-i][j]);
        if(st.size()>=1){
            auto it=st.end();
            it--;
            ans+=(*it);
            st.erase(it);
        }
	}
	rc(ans);
}

Measured memory_bytes: 9856
X,Y=map(int,input().split())
if X==1 and Y==1:
  print(1000000)
elif X==2 and Y==1:
  print(500000)
elif X==3 and Y==1:
  print(400000)
elif X==1 and Y==2:
  print(500000)
elif X==1 and Y==3:
  print(400000)
elif X==2 and Y==2:
  print(400000)
elif X==2 and Y==3:
  print(300000)
elif X==3 and Y==3:
  print(200000)
elif X==3 and Y==2:
  print(300000)
elif X==1 and Y>3:
  print(300000)
elif X==2 and Y>3:
  print(200000)
elif X==3 and Y>3:
  print(100000)
elif X>3 and Y==1:
  print(300000)
elif X>3 and Y==2:
  print(200000)
elif X>3 and Y==3:
  print(100000)
else:
  print(0)

Measured memory_bytes: 3064
#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

struct UnionFindSize {
    vector<int> parent;

    UnionFindSize() {}
    UnionFindSize(const int size) { init(size); }
    void init(const int size) {
        parent.resize(size, -1);
    }
    int operator[](const int x) {
        return parent[x];
    }
    int find(const int x) {
        return parent[x] < 0 ? x : (parent[x] = find(parent[x]));
    }
    int size(const int x) {
        return -parent[find(x)];
    }
    bool same(const int x, const int y) {
        return find(x) == find(y);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        else if (size(x) > size(y)) swap(x, y);
        parent[y] += parent[x];
        parent[x] = y;
        return true;
    }
};

int N, K, L;
UnionFindSize road, line;
map<pair<int, int>, int> counter;

int main() {
    cin >> N >> K >> L;
    road = UnionFindSize(N);
    line = UnionFindSize(N);

    rep(i, K) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }
    rep(i, L) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        line.unite(r, s);
    }    

    rep(i, N) {
        counter[mp(road.find(i), line.find(i))] += 1;
    }

    rep(i, N) {
        int cnt = counter[mp(road.find(i), line.find(i))];
        write(cnt);
    }
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int cnt[100000];
  REP(i,100000)cnt[i]=0;
  int n;
  int h;
  int old_h;
  int mx = 0;
  cin >> n;
  REP(i,n){
      cin >> h;
      if (i==0){
          old_h = h;
      }else{
          if (h<=old_h){
              cnt[i] = cnt[i-1]+1;
              mx = max(cnt[i],mx);
          }else{
              cnt[i] = 0;
          }

          old_h = h;
      }
  }
  cout << mx << endl;
}

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

class Program
{
	static void Main(string[] args)
	{
		int[] ABX = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int A = ABX[0];
		int B = ABX[1];
		int X = ABX[2];
		string ans = "YES";
		if (A + B < X || A > X)
			ans = "NO";
		
		Console.WriteLine(ans);
	}
}


//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 13268
S = input()

if S=='SUN':
    print(7)
elif S=='SAT':
    print(1)
elif S=='FRI':
    print(2)   
elif S=='THU':
    print(3)
elif S=='WED':
    print(4)
elif S=='TUE':
    print(5)
elif S=='MON':
    print(6)    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];

    ll ans = 1e+11;
    vector<int> perm(n, 0);
    for(int i = 0; i < k; ++i)  perm[n - i - 1] = 1;
    do {    // bit が k 個立っている集合の全探索
        int cur = 0;
        ll S = 0;
        for(int i = 0; i < n; ++i){
            if(cur < a[i])  cur = a[i];
            else{
                if(perm[i]){    // bit が立っているならば
                    S += cur - a[i] + 1;
                    ++cur;
                }
            }
        }
        chmin(ans, S);
    } while(next_permutation(perm.begin(), perm.end()));

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <ctime>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		string m;
		cin >> m;
		for(int i=0; i<n; ++i){
			string tmp;
			for(int j=0; j<m.size();){
				int a=(int)(m[j]-'0');
				int cnt=1;
				while(m[j+cnt]==m[j]) ++cnt;
				stringstream ss;
				ss << cnt << a;
				string hoge;
				ss >> hoge;
				tmp+=hoge;
				j+=cnt;
			}
			swap(tmp,m);
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1360
#include<iostream>
using namespace std;
int main(){
  int a,b;
  int ans = 0;
  cin>>a;
  for(int i=105;i<=a;i+=2){
    b=0;
    for(int r=1;r<=i;r+=2) if(i%r==0) b++;
    if(b==8) ans++;
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
vl dp(100005,-1);
vl h(100005);
ll jump(ll i){
	if(dp[i]!=-1)
		return dp[i];
	if(i==1){
		dp[1]=0;
		return dp[i];
	}
	if(i==2){
		dp[2]=abs(h[2]-h[1]);
		return dp[i];
	}
	dp[i]=min(jump(i-1)+abs(h[i]-h[i-1]),jump(i-2)+abs(h[i]-h[i-2]));
	return dp[i];
} 
 
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	cout<<jump(n)<<"\n";
}

Measured memory_bytes: 4224
import sys

input = sys.stdin.readline


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

    ans = -float("inf")
    for t in range(min(N, K) + 1):
        s = K - t
        for l in range(t + 1):
            r = t - l
            gem = V[:l]
            gem += V[-r:] if r != 0 else []
            gem.sort()
            value = sum(gem)
            for i in range(min(s, t)):
                if gem[i] < 0:
                    value -= gem[i]
                else:
                    break
            ans = max(ans, value)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9132
def Warshall_Floyd(edges,N):
  import copy
  d=copy.deepcopy(edges)
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

import sys
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
B=Warshall_Floyd(A,N)
if A!=B:
  print(-1)
  sys.exit()

ans=0
for i in range(N):
  for j in range(i):
    need=1
    for k in range(N):
      if k!=i and k!=j:
        if A[i][j]==A[i][k]+A[k][j]: need=0
    ans+=need*A[i][j]
print(ans)

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

int main() {
  int R, G, B, N;  cin >> R >> G >> B >> N;
  int rcnt = N / R + 1;
  int count = 0;
  for(int i = 0; i < rcnt; i++){
    int gcnt = ( N - R * i ) / G + 1;
    for(int j = 0; j < gcnt; j++){
      int rest = N - R * i - G * j;
      if(rest % B == 0) count += 1;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;


void solve() {
}

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

    cin >> a;
    cout << 3.14159265358979323846 * a * 2.0 << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3792
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

l = [a,b,c,d,e]
if len([i for i in l if i != 0]) == 0:
    m = 10
    
else:
    m = min([i for i in l if i != 0])
n = l.count(0)
ans = (A//10 + B//10 + C//10 + D//10 + E//10)*10 + m + (5-n)*10 -10
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int t = sc.NextInt();

        int answer = int.MaxValue;
        for (int i = 0; i < n; i++)
        {
            int cost = sc.NextInt();
            int time = sc.NextInt();
            if (time <= t)
            {
                answer = Math.Min(answer, cost);
            }
        }

        if (answer == int.MaxValue)
        {
            Console.WriteLine("TLE");
            return;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
   int N,D,cnt=0;
   cin >> N >> D;

   int k = D*2+1;
   while(N > 0){
     N = N-k;
     cnt++;
   }
   cout << cnt << endl;
}


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

#define rep(i, j, n) for (int i = int(j); i < (int)(n); i++)
#define repback(i, n, k) for (int i=int(n); i >= (int)(k); --i)

typedef long long ll;
ll dp[55][55][2550];
int n, a;

int main() {
  while(cin >> n >> a){
	vector<ll> x(n);
    memset(dp, 0, sizeof(dp));

    //dp初期値
    dp[0][0][0] = 1;

    rep(i, 0, n) cin >> x[i];
    
    rep(i, 0, n){
        rep(j, 0, n+1){ //0-index
            rep(k, 0, 2550){
                dp[i+1][j][k] += dp[i][j][k]; //x[i]を選ばなかった
                dp[i+1][j+1][k + x[i]] += dp[i][j][k]; //x[i]を選んだ
            }
        }
    }
    ll ans = 0;
    rep(j, 1, n+1) {
        ans += dp[n][j][a*j];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 60672
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		String[] s = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
		String input = scn.next();
		int j=0;
		for(int i=0;i<=6;i++){
			if(input.equals(s[i])) j=7-i;
		}
		System.out.println(j);
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
int n,m;
int w[N];
bool st[N];
int main()
{
	memset(st,1,sizeof st);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>w[i];
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		int a1=w[a],b1=w[b];
		if(a1<=b1)
			st[a]=0;
		if(b1<=a1)
			st[b]=0;
	}
	int sum=0;
	for(int i=1;i<=n;i++)
		if(st[i])
			sum++;
	cout<<sum<<endl;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int A,B,M,ans,x;
  int amin=100000,bmin=100000;
  
  cin >>A>>B>>M;
  
  vector<int> a(A),b(B);
  vector<vector<int>> m(M,vector<int>(3));
  
  for(int i=0;i<A;i++){
    cin >> a.at(i);
    if(a.at(i)<amin)amin=a.at(i);
  }
  
  for(int i=0;i<B;i++){
    cin >> b.at(i);
    if(b.at(i)<bmin)bmin=b.at(i);
  }
                        
  for(int i=0;i<M;i++){
    for(int j=0;j<3;j++){
      cin >> m.at(i).at(j);
    }
  }
  
  ans = amin + bmin;
  
  for(int i=0;i<M;i++){
    int j = m.at(i).at(0)-1;
    int k = m.at(i).at(1)-1;
    x = a.at(j)+b.at(k)-m.at(i).at(2);
    if(x<ans){
      ans=x;
    }
  }
                        
  cout << ans << endl;
                        
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
bool isSameNum(int a, int c, int s)
{
  if(s == 1){
    if(a / 100 == c){
      return 1;
    }
  }
  
  if(s == 2){
    a /= 10;
    if(a % 10 == c){
      return 1;
    }
  }
  
  if(s == 3){
    if(a % 10 == c){
      return 1;
    }
  }
    
  return 0;
}


int main()
{
  int n, m;
  cin >> n >> m;
  
  vector<int> s(m);
  
  vector<int> c(m);
  for(int i = 0; i < m; i++){
    cin >> s[i] >> c[i];
  }
  
  if(n == 1){
  
  for(int ans = 0; ans < 10; ans++){
      bool frag = 0; 
      for(int i = 0; i < m; i++){
        if(!isSameNum(ans, c[i], s[i] + 2)){
          frag = 1;
        }
      }
      if(!frag){
        cout << ans;
        return 0;
      }
  }
  
    cout << -1;
    return 0;
  }
  
  if(n == 2){
  
  for(int ans = 10; ans < 100; ans++){
      bool frag = 0; 
      for(int i = 0; i < m; i++){
        if(!isSameNum(ans, c[i], s[i] + 1)){
          frag = 1;
        }
      }
      if(!frag){
        cout << ans;
        return 0;
      }
  }
 
    cout << -1;
    return 0;
  }
  
  for(int ans = 100; ans < 1000; ans++){
      bool frag = 0; 
      for(int i = 0; i < m; i++){
        if(!isSameNum(ans, c[i], s[i])){
          frag = 1;
          break;
        }
      }
      if(!frag){
        cout << ans;
        return 0;
      }
  }
  
  cout << -1;
  return 0;
  
}

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

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<string> pictures(h);
  
  for(int i=0; i<h; i++){
    cin >> pictures.at(i);
  }
  
  int newW = w + 2;
  
  for(int i=0; i<newW; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int i=0; i<h; i++){
    cout << "#";
    cout << pictures.at(i);
    cout << "#" << endl;
  }
  
  for(int i=0; i<newW; i++){
    cout << "#";
  }
  cout << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n,s;
    cin>>n>>s;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    int ans = INF;
    int sum=0;
    int r = 0;
    rep(i,n){
        while(sum<s && r<n){
            sum+=v[r];
            r++;
        }
        if(sum<s)break;
        ans = min(ans,r-(int)i);
        sum-=v[i];
    }
    if(ans==INF)cout<<0<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
//#include <cstdio>
//#include <algorithm>
//#include <cmath>
//#include <cstring>
//#include <iostream>
using namespace std;
typedef long long ll;
const int maxx=1e5+100;
const int INF=1e9;
const int MOD=1e9+7;
char s[maxx];
 
int main()
{
    scanf("%s",s);
    for(int i=0; i<strlen(s); i+=2){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S; cin >> S;
  int tcnt = 0, scnt = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'S') {
      ++scnt;
    } else {
      if (scnt > 0) --scnt;
      else          ++tcnt;
    }
  }
  cout << scnt + tcnt << endl;
}


Measured memory_bytes: 3696
c11, c12, c13 = gets.split.map(&:to_i)
c21, c22, c23 = gets.split.map(&:to_i)
c31, c32, c33 = gets.split.map(&:to_i)

if c21 - c11 == c22 - c12 && c22 - c12 == c23 - c13 &&
  c31 - c21 == c32 - c22 && c32 - c22 == c33 - c23 &&
  c12 - c11 == c22 - c21 && c22 - c21 == c32 - c31 &&
  c13 - c12 == c23 - c22 && c23 - c22 == c33 - c32
  puts "Yes"
else
  puts "No"
end



Measured memory_bytes: 1788
#include <iostream>

typedef unsigned long long ull;

int main()
{
  ull N;
  std::cin >> N;
  if (N % 2 == 1)
  {
    std::cout << 0 << std::endl;
    return 0;
  }

  ull ans = 0;
  ull base = 5;
  while (base < N)
  {
    ans += (N / base) / 2;
    base *= 5;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

long long N, K, A[59], dp[59][5009][2], mod = 1000000007;

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

	int A, B, C;
	cin >> A >> B >> C;

	int saidai = max(A, max(B, C));
	co(saidai * 10 + A + B + C - saidai);
	Would you please return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            vector<char> A(n);
            REP(i, n) cin >> A[i];
            if(n == 1) cout << A[0] << " " << 1 << endl;
            else{
                vector<pair<int, char>> B(0);
                bool ok = false;
                pair<char, int> ans;
                REP(i, n){
                    bool fd = false;
                    REP(j, B.size()){
                        if(A[i] == B[j].second){
                            B[j].first++;
                            fd = true;
                            break;
                        }
                    }
                    if(fd != true){
                        B.push_back(make_pair(1, A[i]));
                    }
                    whole(sort, B, greater<>());
                    if(B.size() >= 2 and B[0].first > B[1].first + (n - (i + 1))){
                        ok = true;
                        ans = make_pair(B[0].second, i + 1);
                        break;
                    }
                    else if(B.size() == 1 and B[0].first > n / 2){
                        ok = true;
                        ans = make_pair(B[0].second, i + 1);
                        break;
                    }
                }
                if(ok) cout << ans.first << " " << ans.second << endl;
                else{
                    if(B[0].first == B[1].first) cout << "TIE" << endl;
                    else cout << B[0].second << " " << n << endl;
                }
            }       
        }
    }
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define MN 200000
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int n,f[MN+5],ans,head[MN+5],cnt;
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void dfs(int x,int fa)
{
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa) 
            dfs(e[i].to,x),
            ans=max(ans,f[x]+1+f[e[i].to]),
            f[x]=max(f[x],f[e[i].to]+1);
}
int main()
{
    n=read();
    for(int i=1;i<n;++i) ins(read(),read());
    dfs(1,0);
    puts(ans%3==1?"Second":"First");
    return 0;
}

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

template<typename T>
class BIT
{
//bit[x]
//manage range of bit[x] is (x & -x)
//
public:
	static const int n = 2*110000;
	T bit[n] = {};
	void add(int a, T w)
	{
		for (int x = a; x <= n; x += x & -x)
		{
			bit[x] += w;
		}
	}
	T sum(int a)
	{
		T ret = 0;
		for (int x = a; x > 0; x -= x & -x)
		{
			ret += bit[x];
		}
		return ret;
	}

};

int main()
{
	string s;
	cin >> s;
	int hairetsu[2*110000];
	int n = s.size();
	for (int i = 1; i <= n; ++i)
	{
		hairetsu[i] = (s[i-1] == 'B'?1:0);
	}

	int bla = 0;
	long long int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if(hairetsu[i])
		{
			++bla;
		}
		else
		{
			ans += bla;
		}
	}

	// BIT<long long int> BT;
	// for (int i = 1; i <= n; ++i)
	// {
	// 	BT.add(i, hairetsu[i]);
	// 	if (hairetsu[i] == 0)
	// 	{
	// 		ans += BT.sum(i);
	// 	}
	// 	// cout << i - BT.sum(hairetsu[i]) << " ";
	// }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> K;
    cin >> A >> B;
    int n = intceil(A, K);
    if (A <= n * K && n * K <= B) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
    int n1, n2, n3, total;

    scanf("%d %d %d", &n1, &n2, &n3);

    total = n1+n2+n3;

    if(total >= 22)
    {
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }

    return 0;
}

Measured memory_bytes: 128
from itertools import permutations

N = int(input())
p = tuple(map(int, input().split(' ')))
q = tuple(map(int, input().split(' ')))

pi = None
qi = None
for index, numbers in enumerate(permutations(range(1, N + 1))):
    if numbers == p:
        pi = index
        if qi is not None:
            break
    if numbers == q:
        qi = index
        if pi is not None:
            break

print(abs(pi - qi))


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

int isBeautiful(string str){
  int arr[26] = {0};
  for (int i = 0; i < str.length(); i ++){
    arr[str[i] - 'a'] ++;
  }
  for (int i = 0; i < 26; i ++){
    if (arr[i] % 2 != 0){
      return false;
    }
  }
  return true;
}
int main (){
  string str;
  cin >> str;
  if (isBeautiful(str)){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<math.h>
#include <stdlib.h>

int main()
{
  int A,B, X[3],i, max;
  scanf("%d %d",&A,&B);
  
  X[0]=2*A-1;
  X[1]=2*B-1;
  X[2]=A+B;
  
  max=X[0];
  if(X[1]>max){
    max=X[1];
  }
  if(X[2]>max){
    max=X[2];
  }

  printf("%d",max);
  return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,m,ans=0;
    cin >> n >> m;
    vector<ll> x[n];
    ll h[n];
    for (ll i=0;i<n;i++){
        cin >> h[i];
    }
    for (ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        x[a-1].push_back(b-1);
        x[b-1].push_back(a-1);
    }
    for (ll i=0;i<n;i++){
        bool flag=true;
        for (ll j=0;j<x[i].size();j++){
            if (h[i]<=h[x[i][j]]){
                flag=false;
                break;
            }
        }
        if (flag)ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int arr[3], a, b, c;
	
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr, arr +3);
	if(arr[0] == arr[1] && arr[1] != arr[2]){
		cout << "Yes" << endl;
	}
	else if(arr[1] == arr[2] && arr[1] != arr[0]){
		cout << "Yes" << endl;
	}
	else 
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin>>n;
    for(int i=0;i<n.size();i++)
    {
        if(n[i]=='1') n[i]='9';
        else n[i]='1';
    }
    cout<<n<<endl;
}


Measured memory_bytes: 256
/*  ex3_4
    Rikuta  */

#include <stdio.h>

int main(void){

    int number;
    //numberの読み込み
    scanf("%d",&number);
    //for文を二つ使って1*1から9*9まで全通りを考える．
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {   
            //i*jがnumberとなったときYesを出力して終了．
            if (i*j==number)
            {
                printf("Yes\n");
                return 0;
            }
            
        }
        
    }
    //Noを出力
    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++


def cc(l1,l2):
	return list(set(l1)&set(l2))

def main(io):
	n,m= map(int, io.next().split())
	favs=range(m+1)
	for _ in range(n):
		l=list(map(int, io.next().split()))[1:]
		favs = cc(favs, l)
			
	return len(favs)

#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)

Measured memory_bytes: 2568
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, K;
    cin >> N >> K;

    auto powmod = [&](int a, int p) -> int {
        int ret = 1;
        int mul= a;
        while (p > 0) {
            if (p & 1) (ret *= mul) %= MOD;
            p >>= 1;
            (mul = mul * mul) %= MOD;
        }
        return ret;
    };

    vector<int> dp(K+1);
    for (int k = K; k >= 1; k--) {
        dp[k] = powmod(K/k, N);
        int idx = 2 * k;
        while (idx <= K) {
            dp[k] += MOD - dp[idx];
            dp[k] %= MOD;
            idx += k;
        }
    }

    int ret = 0;
    for (int k = 1; k <= K; k++) {
        (ret += k * dp[k]) %= MOD;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3992
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
const int maxn = 9e5+5;
const int inf = 1e9;

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << (n+1-a)*(n+1-b)<<endl;
}

Measured memory_bytes: 256
w,a,b= (int(i) for i in input().split()) 
if a<=b:
  if b<=a+w:
    print(0)
  if a+w<b:
    print(b-a-w)
if a>b:
  if a<=b+w:
    print(0)
  if b+w<a:
    print(a-b-w)

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

using namespace std;

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

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

int n, h[200010];
ll a[200010], tree[200010];

ll query(int i){	
	ll s = 0;

	while(i > 0){
		s = max(s, tree[i]);
		i -= (i & -i);
	}
	
	return s;
}

void update(int i, ll value){	
	while(i <= n){ 
		tree[i] = max(tree[i], value);
		i += (i & -i);
	}
}


ll solve(){
	
	for(int i=1; i<=n; i++){
		ll s = query(h[i]) + a[i];
		
		update(h[i], s);
	}	
	
	return query(n);
}

int main() {	
	cin.sync_with_stdio(0);
	cin.tie(0);
	cin >> n;

	for(int i=1; i<=n; i++)
		cin >> h[i];	
	for(int i=1; i<=n; i++)
		cin >> a[i];	
	
	
	cout << solve() << endl;

	return 0;	
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    ll sum = 0,cnt = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        sum += abs(a[i]);
        if (a[i] < 0) cnt++;
    }
    if (cnt % 2 == 0){
        cout << sum << endl;
    } else {
        ll mn = MM;
        for (int i = 0; i < N; i++){
            mn = min(abs(a[i]),mn);
        }
        cout << sum - 2*mn << endl;
    }
}

Measured memory_bytes: 1024
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        long S = 1;
        long ans =0;
        
        if(N%2==0) {
        	ans=N/10;
        	for(long i=50;i<=N;i=i*5) {
        		ans=ans+N/i;
        	}
        } else {
        	ans = 0;
        }
        System.out.println(ans);	
        
        
    }
    

}

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


int main()
{
  vector<bool> prime(100001, false);
  prime[2] = true;
  for (int i=3; i<100001; i+=2)
  {
    int j = 3;
    bool flag = true;
    while (j * j <= i)
    {
      if (i % j == 0)
      {
        flag = false;
        break;
      }
      j += 2;
    }
    prime[i] = flag;
  }
  vector<int> csum(100001, 0);
  for (int i=3; i<100001; i++)
    if (prime[i] && prime[(i+1)/2])
      csum[i] = csum[i-1] + 1;
    else
      csum[i] = csum[i-1];
  int q;
  cin >> q;
  rep(i, q)
  {
    int l, r;
    cin >> l >> r;
    printf("%d\n", csum[r] - csum[l-1]);
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
template <typename T> using
Treap = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr <<name<<" : "<<arg1<< "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) <<" : "<<arg1<<" , "; __f( comma+1 , args...);}

typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        #ifdef forthright48
            freopen( "input.txt" , "r" , stdin );
        #endif // forthright48
        int len;
        string s;
        cin >> len >> s;
        int r = 0 , b = 0;
        for( int i = 0; i < s.size(); i++ ) {
                if( s[i] == 'R' ) r++;
                else b++;
        }
        cout << ( r > b ? "Yes" : "No" ) <<endl;
        return 0;
}











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

int main() {
	float x;cin >> x;
	int rt = (int)sqrt(x);
	float max_e = 1.0;
	while(rt > 1) {
		float e = 1.0;
		while(true) {
			float be = pow(rt, e);
			if (be > x) break;
			if (max_e < be) max_e = be;
			e += 1.0;
		}
		rt -= 1.0;
	}
	cout << (int)max_e << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
const ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	ll sum=0;
	ll ret=0;
	cin>>N;
	FOR(i,N) {
		cin>>x;
		ret+=sum*x%mo;
		(sum+=x)%=mo;
	}
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    char S;
    map<char,int> m;
    while(cin >> S){
        m[S]++;
    }
    rep(i,26){
        cout << (char)('a'+i) << " " << ':'
        <<" "<< m[(char)i+'a']+m[(char)i+'A'] << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int i=0;
        int [] tree=new int [n];
        
        int [] tree1=new int [n];
        while(i<n)
        {
            tree[i] = sc.nextInt();
            i++;
        }
        Arrays.sort(tree);
        int m=n;
        for(i=0;i<n;i++)
        {
            tree1[i]=tree[m-1];
            m--;
        }
        
        
        
        int [] result = new int[n];
        for(i=0;i+k<=n;i++)
        {
            int j = i;
            result[i]=tree1[j]-tree1[j+k-1]; 
            j++;
            
        }
        Arrays.sort(result);
        System.out.println(result[n-i]);
        
    }

}

Measured memory_bytes: 51300
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  vector<tuple<int, int, int>> T;
  rep(i, N) {
    int s, t, x; cin >> s >> t >> x;
    T.push_back(tuple<int, int, int> (s - x, 1, x));
    T.push_back(tuple<int, int, int> (t - x, 0, x));
  }
  sort(T.begin(), T.end());
  set<int> S;
  int j = 0;
  rep(i, Q) {
    int d; cin >> d;
    while(get<0>(T[j]) <= d && j < 2 * N) {
      if(get<1>(T[j]) == 1) S.insert(get<2>(T[j]));
      if(get<1>(T[j]) == 0) S.erase(get<2>(T[j]));
      j ++;
    }
    if(S.empty()) cout << -1 << "\n";
    if(!(S.empty())) {
      int X = *(S.begin()); cout << X << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 15468