akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B));

        sc.close();
    }

    static int solve(int A, int B) {
        return Math.max(Math.max(A + B, A - B), A * B);
    }
}

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

const int N = 100010;

bool vis[N];
int cnt[N];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	vis[1] = true;
	for (int i = 1; i <= n; ++ i){
		cnt[i] = 1;
	}
	for (int i = 0, x, y; i < m; ++ i){
		scanf("%d%d", &x, &y);
		if (vis[x]){
			vis[x] = cnt[x] > 1;
			vis[y] = true;
		}
		-- cnt[x];
		++ cnt[y];
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i){
		ans += vis[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 768
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    if(A >= 10 || B >= 10) {
        console.log(-1);
        return;
    }
    
    if(A <= 0 || B <= 0) {
        console.log(-1);
        return;
    }
    
    console.log(A * B);
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int main() {
  string S; cin >> S;
  S[3] = '8';
  cout << S << endl;
}

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

int main() {
  //入力M
  int M;
  int x;	//12月30日から次の年になるまでの時間
  int time = 48;
  
  cin >> M;	//入力
  
  x = time - M;
  
  cout << x << endl; 
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,l,r,ans;
int main(){
	scanf("%d%d%d",&n,&l,&r);
	while(n--){
		int x;
		scanf("%d",&x);
		if(x<l||x>=r)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    int a[100010];
    cin >> n >> x;

    long long int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n-1; i++){
        if(a[i] + a[i+1] >= x){
            int diff = (a[i] + a[i+1]) - x;
            ans += diff;
            if(a[i+1] >= diff){
                a[i+1] -= diff;
            }
            else{
                a[i+1] = 0;
               a[i]=a[i]-(diff-a[i+1]);
            }
        }
    }
   // if(a)
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    vector<tuple<int, int, int, int>> ans;
    rep(i, h) {
        rep(j, w) {
            if (i == h-1 && j == w-1) break;
            if (i % 2 == 0) {
                if (a[i][j] % 2 == 1) {
                    if (j == w-1) {
                        ++a[i+1][j];
                        --a[i][j];
                        ans.emplace_back(i, j, i+1, j);
                    }
                    else {
                        ++a[i][j+1];
                        --a[i][j];
                        ans.emplace_back(i, j, i, j+1);
                    }
                }
            }
            else {
                if (a[i][w-1-j] % 2 == 1) {
                    if (j == w-1) {
                        ++a[i+1][w-1-j];
                        --a[i][w-1-j];
                        ans.emplace_back(i, w-1-j, i+1, w-1-j);
                    }
                    else {
                        ++a[i][w-1-j-1];
                        --a[i][w-1-j];
                        ans.emplace_back(i, w-1-j, i, w-1-j-1);
                    }
                }
            }
        }
    }
    cout << ans.size() << endl;
    for (auto ap: ans) {
        cout << get<0>(ap) + 1 << " " << get<1>(ap) + 1 << " " << get<2>(ap) + 1 << " " << get<3>(ap) + 1 << endl; 
    } 
    return 0;
}

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

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

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

    ll res = t;
    ll prev = a[0] + t;
    rep1(i, n){
        res += t - max(0ll, prev-a[i]);
        prev = a[i] + t;
    }

    cout << res << endl;


    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[3005][3005][5];
ll g[3005][3005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll ans=0;
  if(s=="RRR") ans=3;
  else if(s=="SRR" || s=="RRS") ans=2;
  else if(s=="SSS") ans=0;
  else ans=1;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,y;
  scanf("%d %d\n",&n,&y);

  int m = 0;
  int count =0;
  if (n*10000 < y){
    printf("-1 -1 -1\n" );
    return 0;
  }
  int j,res,num;
  for (int i = n; i >=0; i--) {
    res = y-i*10000;

    if ((5000*(n-i)-res)%4000==0) {
        j=(5000*(n-i)-res) / 4000;
        if (j>=0&&n-i-j>=0){
        printf("%d %d %d\n",i,n-i-j,j );
        return 0;
      }
      }
    }

  printf("-1 -1 -1\n" );
  return 0;
}


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

#define REP(i, n) for ( int i = 0; i < (n); i++ )

int a[110][110];

int main() {

    int r, c;

    std::cin >> r >> c;

    REP(i, r) REP(j, c) std::cin >> a[i][j];

    REP(i, r) REP(j, c)     a[i][c] += a[i][j];
    REP(i, r) REP(j, c + 1) a[r][j] += a[i][j];

    REP(i, r + 1) {

        REP(j, c + 1) {
            if ( j ) std::cout << " ";
            std::cout << a[i][j];
        }

        std::cout << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3128
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
double R;
int main() {
	cin >> R;
	cout << 2 * R * 3.1415926535;
	return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

// デバッグを消し忘れるな！！！

int main() {
    ll x, y; cin >> x >> y;
    rep(i, 0, 100){
        rep(j, 0, 100){
            ll m = i*2 + j*4;
            if(m == y && i+j == x){
                co("Yes");
                return 0;
            }
        }
    }
    co("No");

    return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int t[1123],n[1123],m[1123],s[1123],N,M,r,i,j,k;
  int stud[1269];
  while(1){
    cin>>N>>M;
    // cout<<N<<","<<M<<endl;
    if(N==0 && M==0)
      break;
    cin>>r;
    for(i=0;i<r;i++){
      cin>>t[i]>>n[i]>>m[i]>>s[i];
    }
    int q,ts,te,mm,re=0;
    cin>>q;
    for(i=0;i<q;i++){
      re=0;
      cin>>ts>>te>>mm;
      fill(stud,(stud+1269),0);
      for(j=0;j<r;j++)
	if(m[j]==mm)stud[t[j]]+=(s[j]?1:-1);
      for(j=0;j<=1260;j++){
	stud[j+1]+=stud[j];
	re+=(stud[j]>0)&&(ts<=j)&&(j<te);
      }
      cout<<re<<endl;
    }
   }
  return 0;
}
      

Measured memory_bytes: 1180
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<char> A){rep(i,A.size()){cout << A[i];}cout << endl;}

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1;i*i <= n;i++){
        if(n%i != 0) continue;
        ll j = n/i;
        ans = min(ans,i+j-2);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#define MOD 1000000007

using namespace std;

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

    int n,m;
    cin>>n>>m;

    if(n>m)
        swap(n,m);

    if(m-n>1)
    {
        cout<<"0\n";
        return 0;
    }

    int rez=1;
    for(int i=1; i<=n; i++)
        rez=(1LL*rez*i)%MOD;
    for(int i=1; i<=m; i++)
        rez=(1LL*rez*i)%MOD;

    if(m-n==0)
        rez=(2LL*rez)%MOD;

    cout<<rez<<"\n";
    return 0;
}


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

using namespace std;

int main(){
    int N,b[101],ans;
    cin >> N;
    for(int i=1;i<N;i++){
        cin >> b[i];
    }
    ans = b[N-1] + b[1];
    for(int i=2;i<=N-1;i++){
        ans += min(b[i-1],b[i]);
    }
    cout << ans << endl;
}

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

int main() {
    char b;
    cin >> b;
    if(b == 'A')cout << 'T' << endl;
    if(b == 'T')cout << 'A' << endl;
    if(b == 'G')cout << 'C' << endl;
    if(b == 'C')cout << 'G' << endl;
}

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

int main(){
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
    sort(a.begin(), a.end(), greater<pair<int, int>>());
    int all_a = 0;
    int all_b = 0;
    for (int i = 0; i < n; i++){
        all_a += a[i].second;
        all_b += a[i].first;
    }
    if (all_a < t){
        cout << all_b << endl;
        return 0;
    }
    int ans = 0;
    vector<int> dp(t, 0);
    vector<int> n_dp(t, 0);
    for (int i = 0; i < min(n, 100); i++){
        for (int j = 0; j < t; j++) dp[j] = 0;
        for (int j = 0; j < n; j++){
            if (i == j) continue;
            if (a[j].second >= t) continue;
            n_dp = dp;
            n_dp[a[j].second] = max(n_dp[a[j].second], a[j].first);
            for (int k = 0; k < t; k++){
                if (k + a[j].second >= t) break;
                n_dp[k + a[j].second] = max(n_dp[k + a[j].second], dp[k] + a[j].first);
            }
            dp = n_dp;
        }
        int tmp = *max_element(dp.begin(), dp.end());
        ans = max(ans, tmp + a[i].first);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
L,R = [int(i) for i in input().split()]

length = min(2019,R-L)
# 右端値はL+2019か、R-Lでよい
R = L + length

ans = 9999999999999999
for i in range(L,R+1) :
    for j in range(i+1,R+1) :
        v = (i * j) % 2019
        if (v < ans) :
            ans = v

print(ans)

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

int main(){
	int a;
	cin>>a;
	for(int i=0;i<26;i++){
		for(int j=0;j<16;j++){
			if(4*i+7*j==a){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
while True:
    [n, m] = [int(x) for x in raw_input().split()]
    if [n, m] == [0, 0]:
        break

    hoge = range(1, n + 1)

    data = []
    for x in range(0, n - 2):
        for y in range(x + 1, n - 1):
            for z in range(y + 1, n):
                s = hoge[x] + hoge[y] + hoge[z]
                if s == m:
                    data.append(s)

    print(len(data))

Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  
  map<string, int> m;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    
    sort(s.begin(), s.end());
    ans += m[s];
    m[s]++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(void)
{
  int n; cin >> n;
  for (int i=1; i<=9; ++i) {
    for (int j=1; j<=9; ++j) {
      if (n == i*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int C=gi();
	    int[][] D=new int[C][C];
	    int[][] c=new int[N][N];
	    for(int i=0;i<C;i++) {
	    	for(int j=0;j<C;j++) {
		    	D[i][j]=gi();
		    }
	    }

	    for(int i=0;i<N;i++) {
	    	for(int j=0;j<N;j++) {
		    	c[i][j]=gi()-1;
		    }
	    }

	    Pair<Integer,Integer>[][] ps=new Pair[3][C];
	    for(int i=0;i<3;i++) {
            for(int j=0;j<C;j++) {
            	int iwa=0;
            	for(int k=0;k<N;k++) {
            		for(int l=0;l<N;l++) {
        		    	if((k+l)%3==i) {
        		    		int col=c[k][l];
        		    		iwa+=D[col][j];
        		    	}
        		    }
    		    }
            	ps[i][j]=new Pair<Integer,Integer>(iwa, j);
		    }
            Arrays.parallelSort(ps[i]);
	    }

	    int ans=Integer.MAX_VALUE;
	    for(int i=0;i<3;i++) {
            for(int j=0;j<3;j++) {
            	for(int k=0;k<3;k++) {
                    Pair<Integer,Integer> p1=ps[0][i];
                    Pair<Integer,Integer> p2=ps[1][j];
                    Pair<Integer,Integer> p3=ps[2][k];
                    if(p1.getValue()==p2.getValue() || p2.getValue()==p3.getValue() || p3.getValue()==p1.getValue()) {
                    	continue;
                    }
                    ans=Math.min(ans, p1.getKey()+p2.getKey()+p3.getKey());
    		    }
		    }
	    }




	    System.out.println(ans);
	}

	public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
		/** serialVersionUID. */
	    private static final long serialVersionUID = 6411527075103472113L;

	    public Pair(final K key, final V value) {
	        super(key, value);
	    }

		@Override
		public int compareTo(Pair<K, V> o) {

			Comparable key = (Comparable)this.getKey();
			Comparable key2 = (Comparable)o.getKey();

			return key.compareTo(key2);
		}

	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  int total = 0;
  for (int i = 0; i < N; i++) {
    int a = 0;
    int b = 0;
    for (int j = 0; j < N; j++) {
      if (s.at(i) == s.at(j)) {
        a++;
      }
    }
    
    for(int j = 0; j < M; j++) {
      if (s.at(i) == t.at(j)) {
        b++;
      }
    }
    if (total < a - b) {
      total = a - b;
    }
  }
  cout << total << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])); 
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    double a = sc.nextInt();
    double b = sc.nextInt();
    double C = sc.nextInt();
    double radian = Math.toRadians(C);
    double sinC = Math.sin(radian);
    double cosC = Math.cos(radian);
    double a2 = Math.pow(a,2);
    double b2 = Math.pow(b,2);
     
    double S = a*b*sinC/2;
    double L = a+b+Math.sqrt(a2+b2-2*a*b*cosC);
    double h = 2*S/a;
    System.out.println(S+" "+L+" "+h);
  }
}


Measured memory_bytes: 26104
x, y = list(map(int, input().strip().split(' ')))
a = list(map(int, input().strip().split(' ')))
class health:
  def __init__(self, x, y, a):
    self.x = x
    self.y = y
    self.a = a
  def decrease_health(self, i):
    self.x = self.x-self.a[i]
monster = health(x, y, a)
for i in range(len(a)):
  monster.decrease_health(i)
if(monster.x <= 0): print('Yes')
else: print('No')



Measured memory_bytes: 13964
n,y=map(int,input().split())
y//=1000
cnt=[0,0,0]
if n>y or n*10<y:print("-1 -1 -1")
else:
    for i in range(y//10+1):
        for j in range(y//5+1 - i):
            if i+j<=n and y-i*10-j*5==n-i-j:
                print("{} {} {}".format(i,j,n-i-j))
                exit()
    else:print("-1 -1 -1")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int h, w; cin >> h >> w;
  for(int j; j<h+2; j++){
    if(j==0||j==h+1){
      for(int x; x<w+2; x++)  cout << "#";
    }
    else{
      if(j==1) cout << endl;
      string s; cin >> s; cout << "#" << s << "#" << endl;
    }
  }
  for(int i; i<w+2; i++)  cout << "#";
  cout << endl;
}

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

int main()
{
	vector<int> used(100000,0);
	int a,b,c;
	cin >> a >> b >> c;
	int now = 1;
	int m = 1;
	for(int i = 1;i<2000;i++)
	{
		now = a*(m++);
		now %= b;
		if(now==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}


Measured memory_bytes: 3724
# dfsでみる どうせ小さいので都度配列を渡していい
# 隣接リストでもつことにする
# クラスで管理するのすらめんどくさいのでlistオブジェクトでいいや

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    s, t = map(int, input().split())
    graph[s - 1].append(t - 1)
    graph[t - 1].append(s - 1)

ans = 0

path = [0, [0]]
stack = [path]

while len(stack) > 0:
    cur = stack.pop()
    if len(cur[1]) == n:
        ans += 1
    else:
        for g in graph[cur[0]]:
            if g not in cur[1]:
                nex = cur[1][:]
                nex.append(g)
                stack.append([g, nex])

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
// typedef long long ll;
int main()
{
  double n;
  cin >> n;
  if((int)n %2 == 0)  {cout <<setprecision(10)<< 0.50 << endl;}
  else{ cout<<setprecision(10) << (n + 1)/(2*n) << endl;}
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
int main() {
	int n;
	cin >> n;
	cout << n*(n + 1) / 2 << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector<ll> cnt(101010, 0);
vector<ll> mo(101010, 0);

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

    ll N, M;
    cin >> N >> M;

    vector<ll> X(N);
    REP(i, N) cin >> X[i];

    REP(i, N) cnt[X[i]]++;
    REP(i, 101010) mo[i%M] += cnt[i];
    
    ll res = 0;
    res += mo[0]/2;
    if(M%2==0) res += mo[M/2]/2;

	REP(i, (M-1)/2){
		int x = i+1;
		int y = M-x;
		ll sumx = mo[x],sumy = mo[y];
		if(sumx > sumy) swap(x, y), swap(sumx, sumy);
		//dump(x) dump(y)
		for(int k=y;k<101010;k+=M){
			while(cnt[k]>=2 && sumy-2 >= sumx){
				cnt[k] -= 2;
				sumy -= 2;
				res++;
			}
		}
		res += sumx;
		//dump(res)
	}
	cout << res << endl;
    return 0;
}

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

int main(void){
  int n, m, k, temp;
  cin >> n >> m;
  int a[m];
  for(int i = 0; i < m; i++ ) a[i] = 0;
  for(int i = 0; i < n; i++){
    cin >> k;
    for(int j = 0; j < k; j++){
      cin >> temp;
      a[temp - 1]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < m; i++) if(a[i] == n) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = gets.chop.split("")
char = s.uniq
ans = s.length
char.each do |c|
	t = s.clone
	n = 0
	until t.length == 1 || t == (c*(t.length)).split("")
		(t.length-1).times do |i|
			if t[i] == c || t[i+1] == c
				t[i] = c
			end
		end
		t = t[0,t.length-1]
		n += 1
	end
	ans = n if n < ans
end
puts ans


Measured memory_bytes: 2428
#include <iostream>
#include <algorithm>

using namespace std;

int N,W,v[100],w[100],dp[100][100000];

int maxval(int _d,int _w)
{
	if((_w > 0 && _d < N))
	{
		if(dp[_d][_w] != 0)
		{
			return dp[_d][_w];
		}
		else
		{
			int res1 = 0;
			if(w[_d] <= _w)
			{
				res1 = maxval(_d + 1,_w - w[_d]) + v[_d];
			}
			int res2 = maxval(_d + 1,_w);
			dp[_d][_w] = max(res1,res2);
			return max(res1,res2);
		}
	}
	else
		return 0;
}

int main(void)
{
	cin >> N >> W;
	for(int i = 0;i < N;i++)
	{
		cin >> v[i] >> w[i];
	}
	int result = maxval(0,W);
	cout << result << "\r\n";
	return 0;
}

Measured memory_bytes: 7180
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

ll n, m;
ll f[100005];
ll v[limit], w[limit];

void solveProblem() {
    REP(i, 1, 100000) f[i] = maxN;

    REP(i, 1, n) {
        REPD(j, 100000, v[i]) {
            f[j] = min(f[j], f[j - v[i]] + w[i]);
        }
    }

    ll ans = 0;
    REP(i, 0, 100000) ans = (f[i] <= m ? i : ans);

    cout << ans << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n >> m;
    REP(i, 1, n) cin >> w[i] >> v[i];
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 4448
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<double> v(n);
	for (auto& x : v) cin >> x;
	sort(v.begin(), v.end());
	double cur = v[0];
	for (int i = 1; i < v.size(); i++)
	{
		cur = (cur + v[i]) / 2;
	}
	printf("%.15f\n", cur);
	return 0;
}

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

using namespace std;

bool isBlack[100][100];

void flip()
{
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 50; j++)
            swap(isBlack[j][i], isBlack[99 - j][i]);
    }
}

void next(int &r, int &c)
{
    if (c == 98)
    {
        c = 0;
        r += 2;
    }
    else
    {
        c += 2;
    }
}

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 50; i++)
    {
        fill(isBlack[i], isBlack[i] + 100, true);
    }
    int r = 0;
    int c = 0;
    while (--a)
    {
        isBlack[r][c] = false;
        next(r, c);
    }
    flip();
    r = c = 0;
    while (--b)
    {
        isBlack[r][c] = true;
        next(r, c);
    }
    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            if (isBlack[i][j])
                cout << "#";
            else
                cout << ".";
        }
        cout << "\n";
    }
    return 0;
}


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<long long> A(N), B;
    for(int i = 0; i < N; i++) cin >> A[i];
    B = A;
    sort(B.rbegin(), B.rend());
    long long M = *max_element(A.begin(), A.end());
    if(M == B[1]){
        for(int i = 0; i < N; i++) cout << M << endl;
    }else{
        for(int i = 0; i < N; i++){
            if(A[i] == M) cout << B[1] << endl;
            else cout << M << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4736
# coding: utf-8
N=int(input())

num_a=ord("a")

ans=""
flg=True

X_dumy = N
while X_dumy>0:
    X_dumy-=1
    out = X_dumy%26
    X_dumy = X_dumy//26
    ans=chr(num_a+(out)%26)+ans


print(ans)


Measured memory_bytes: 61612
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

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

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, K;
int a[200000];

void init()
{
}

void solve()
{
    map<ll, ll> m;
    REP(i, N){
        if(m.find(a[i]) == m.end()) m[a[i]] = 1;
        else m[a[i]]++;
    }
    vector<ll> v;
    ll ans = 0;
    ll n = 0;
    for(auto it = m.begin(); it != m.end(); it++){
        n++;
        v.pb(it->se);
    }
    if(n > K){
        sort(ALL(v));
        REP(i, n-K) ans += v[i];
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 15732
program ABC149C
    implicit none
    integer::X
    integer::i,j
    logical::flag
    read*,X
    do i=X,10**5+3
        flag=.true.
        do j=2,int(sqrt(real(X)+1))
            if(mod(i,j)==0)then
                flag=.false.
                exit
            endif
        end do
        if(flag)then
            print"(i0)",i
            stop
        endif
    end do
end program ABC149C

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using LL=long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> S( N );
    for( int i = 0; i < N; i++ )
    {
        cin >> S[ i ];
    }
    for( int i = 0; i < M; i++ )
    {
        string T;
        cin >> T;
        if( S[ i ].find( T ) == string::npos )
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var K, N int
	fmt.Scan(&K, &N)

	var MaxDistance float64
	var A int
	As := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A)
		As[i] = A
		if i >= 1 {
			MaxDistance = math.Max(float64(MaxDistance), float64(A-As[i-1]))
			// fmt.Println(MaxDistance, float64(As[i-1]-A))
		}
		// fmt.Println(As)
	}

	res := K - As[len(As)-1] + As[0]
	// fmt.Println(res, MaxDistance, K)
	if res < int(MaxDistance) {
		res = int(MaxDistance)
	}
	fmt.Println(K - res)

}


Measured memory_bytes: 6784
import sys
N,K=map(int,input().split())
alist=list(map(int,input().split()))
flist=list(map(int,input().split()))
alist.sort()
flist.sort(reverse=True)
#print(alist)
#print(flist)

def check(m):
  cnt=0
  for i in range(N):
    if alist[i]*flist[i]>m:
      cnt+=-(-(alist[i]*flist[i]-m)//flist[i])
  
  #print(m,cnt,K)
  if cnt<=K:
    return True
  else:
    return False

if sum(alist)<=K:
  print(0)
  sys.exit(0)

baseline=0
for i in range(N):
  baseline=max(baseline,alist[i]*flist[i])
#print(baseline)

l,r=0,baseline
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  if not check(mid-1) and check(mid):
    print(mid)
    break
  elif not check(mid):
    l=mid+1
  else:
    r=mid-1

Measured memory_bytes: 119628
import java.util.Scanner;

public class Main {

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

		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

		if (U.equals(S))
			A--;
		else if (U.equals(T))
			B--;

		System.out.println(A + " " + B);

		scanner.close();
	}

}


Measured memory_bytes: 21332
ans = 0

def dfs():
    global ans
    if len(A) == n:
        count = 0
        for i in range(q):
            if A[b[i] - 1] - A[a[i] - 1] == c[i]:
                count += d[i]
        if count > ans: ans = count
        if A[-1] != m:
            A[-1] += 1
            dfs()
        else:
            A.pop(-1)
        return
    else:
        A.append(A[-1])
        dfs()
        if A[-1] != m:
            A[-1] += 1
            dfs()
        else:
            A.pop(-1)
        return

n,m,q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int, input().split())
A = []

for i in range(1,m + 1):
    A.append(i) 
    dfs()
print(ans)

Measured memory_bytes: 9208
#!/usr/bin/env python3
#EDPC K

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
dp = [False]*(k+1)
for i in range(k+1):
    for j in a:
        if j <= i:
            if not dp[i-j]:
                dp[i] = True
if dp[-1]:
    print('First')
else:
    print('Second')

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

using namespace std;

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

const int N = 2000 + 5;

int n;
char s[N];
vector<int> v[N];

int sum;

void dfs(int p, int x, int d) {
  if(s[x] == '1') {
    sum += d;
  }
  for(auto u : v[x]) {
    if(u != p) {
      dfs(x, u, d + 1);
    }
  }
}

priority_queue<int> q[N];

void dfs2(int p, int x, int d, int& need) {
  if(s[x] == '1') {
    q[x].push(d);
  }
  for(auto u : v[x]) {
    if(u != p) {
      dfs2(x, u, d + 1, need);
      while(q[x].size() and q[x].top() > d and q[u].size() and q[u].top() > d) {
        int v = -1;

        v = q[x].top();
        q[x].pop();
        q[x].push(v - 1);

        v = q[u].top();
        q[u].pop();
        q[u].push(v - 1);

        need -= 2;
      }
      if(q[u].size() > q[x].size())
        swap(q[x], q[u]);
      while(q[u].size()) {
        q[x].push(q[u].top());
        q[u].pop();
      }
    }
  }
}

/*
6
101011
1 2
2 3
2 4
4 5
4 6

7
1111000
1 7
2 7
6 7
5 6
3 5
4 5
*/

int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for(int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int ans = 1e9;
  for(int i = 1; i <= n; i++) {
    // vector<priority_queue<int>> q(v[i].size());
    // priority_queue<ii> vals;
    priority_queue<int> vals;
    int id = 0;
    int sum_all = 0;
    vector<ii> sums;
    for(auto u : v[i]) {
      sum = 0;
      dfs(i, u, 1);
      sums.push_back({sum, u});
      sum_all += sum;
      // if(!q[id].empty()) {
      //   vals.push({q[id].top(), id});
      // }
      if(sum) {
        vals.push(sum);
      }
      id++;
    }
    // auto del = [&](int x) {
    //   int top = q[x].top();
    //   q[x].pop();
    //   if(top > 1)
    //     q[x].push(top - 1);
    //   // printf("pop %d->%d\n", x, top);
    //   if(q[x].size()) {
    //     // printf("add %d\n", q[x].top());
    //     vals.push({q[x].top(), x});
    //   }
    // };

    // int res = 0;
    // while(vals.size() > 1) {
    //   // int x = vals.top().second; vals.pop();
    //   // int y = vals.top().second; vals.pop();
    //   int x = vals.top(); vals.pop();
    //   int y = vals.top(); vals.pop();
    //   // del(x);
    //   // del(y);
    //   if(x > 1)
    //     vals.push(x - 1);
    //   if(y > 1)
    //     vals.push(y - 1);
    //   res++;
    // }
    // if(vals.empty())
    //   ans = min(ans, res);
    if(sum_all % 2)
      continue;
    id = -1;
    int id_sum = 0;
    for(auto x : sums) {
      if(x.first > sum_all - x.first) {
        id_sum = x.first;
        id = x.second;
      }
    }
    if(id == -1) {
      ans = min(ans, sum_all / 2);
      continue;
    }
    int need = id_sum - (sum_all - id_sum);
    for(int i = 1; i <= n; i++) {
      while(q[i].size())
        q[i].pop();
    }
    dfs2(i, id, 1, need);
    if(need <= 0)
      ans = min(ans, sum_all / 2);
  }
  printf("%d\n", ans > 8e8 ? -1 : ans);
  return 0;
}

Measured memory_bytes: 7296
N = int(input())
 
def add(a, b):
    mod = 10**9 + 7
    return (a + b) % mod
  
def mul(a, b):
    mod = 10**9 + 7
    return ((a % mod) * (b % mod)) % mod

def sub(a, b):
    mod = 10**9 + 7
    return (a + mod - b) % mod
  
def mypow(a, n, mod):
    val = 1
    for k in range(n):
        val = mul(val, a)
    return val

ans = add(mypow(10, N, mod=10**9+7), mypow(8,N, mod=10**9+7))
ans = sub(ans, mul(2, mypow(9, N, mod=10**9+7)))
print(ans)



Measured memory_bytes: 9208
require 'matrix'

n, m, l = gets.split.map(&:to_i)
x = []
a = Matrix[*n.times.with_object([]) {|_, x| x << gets.split.map(&:to_i) }]
b = Matrix[*m.times.with_object([]) {|_, x| x << gets.split.map(&:to_i) }]
puts (a * b).to_a.map {|r| r.join ' ' }.join ?\n

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	map<int, int> x;
	for (int i = 0; i < n; i++) {
		int xx;
		cin >> xx;
		x[xx]++;
	}
	vector<int> go;
	for (auto &y : x) {
		if (y.second >= 2) {
			go.push_back(y.first);
		}
		if (y.second >= 4) {
			go.push_back(y.first);
		}
	}
	sort(go.rbegin(), go.rend());
	if ((int)go.size() <= 1) {
		puts("0");
	} else {
		printf("%lld\n", 1LL * go[0] * go[1]);
	}
}



Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1'000'000'000ll + 7;
const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 3 * 100'000 + 5;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
 	string s;
 	int sum=0;
 	cin>>s;
 	for(int i=0;i<s.size();i++) 
 	{
 		if(s[i]==50) sum++;
	 }
	 cout<<sum;
	return 0;
}


Measured memory_bytes: 256
<?php
	fscanf(STDIN, "%d %d", $a, $b);

	if(($a >= 0 && $a <= 10000) && ($b >= 0 && $b <= 10000))
	{
		$result = $a * $b;
		if($result % 2 === 0)
		{
			echo 'Even';
		}
		else
		{
			echo 'Odd';
		}
	}
?>

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	bool isZero = false;
	int countMinus = 0;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			isZero = true;
		}
		else if (a[i] < 0) {
			countMinus++;
			a[i] *= -1;
		}
		ans += a[i];
	}
	if (isZero || countMinus % 2 == 0) {
		cout << ans << endl;
	}
	else {
		sort(a.begin(), a.end());
		cout << ans - a[0] * 2 << endl;
	}






	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll h,n;
  cin>>h>>n;
  ll s=0;
  ll x;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    s+=x;
  }
  if(s>=h)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int j_wa[1005][1005],o_wa[1005][1005],i_wa[1005][1005];
int ans,j,ii,o,a,b,c,d,n,m,k;
char planet;

int main(){
    cin >> m >> n >> k;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            cin >> planet;
            if(planet=='J')j_wa[j][i]++;
            if(planet=='O')o_wa[j][i]++;
            if(planet=='I')i_wa[j][i]++;
            j_wa[j][i]+=j_wa[j-1][i];
            o_wa[j][i]+=o_wa[j-1][i];
            i_wa[j][i]+=i_wa[j-1][i];
        }
        for(int j=1;j<=n;j++){

            j_wa[j][i]+=j_wa[j][i-1];
            o_wa[j][i]+=o_wa[j][i-1];
            i_wa[j][i]+=i_wa[j][i-1];
        }

    }


    for(int i=0;i<k;i++){
            j=0,o=0,ii=0;
    cin >> a >> b >> c >> d;
    j=j_wa[d][c],o=o_wa[d][c],ii=i_wa[d][c];

    j=j-j_wa[b-1][c]-j_wa[d][a-1];
    o=o-o_wa[b-1][c]-o_wa[d][a-1];
    ii=ii-i_wa[b-1][c]-i_wa[d][a-1];

    j+=j_wa[b-1][a-1];
    o+=o_wa[b-1][a-1];
    ii+=i_wa[b-1][a-1];

    printf("%d %d %d\n",j,o,ii);

    }


 return 0;
}

Measured memory_bytes: 12964
#include <iostream>
#include <set>
#define llint long long

using namespace std;

llint a, b, c;

int main(void)
{
  cin >> a >> b >> c;
  llint p = a+b;
  for(int i = 0; i < 100; i++){
    if((60*i+c)%p <= a){
      cout << (60*i+c) << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}



Measured memory_bytes: 3116
n = int(input())
s = input()
ans = ''
i = 0
prev = ''
while i < n - 1:
    if prev != s[i]:
        ans += s[i]
    prev = s[i]
    if s[i] == s[i+1]:
        i += 2
    else:
        i += 1
if not(i > n - 1):
    if prev != s[i]:
        ans += s[i] 
print(len(ans))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pair<int,int>>
#define w(t) int t;cin>>t;while(t--)
#define pi pair<int,int>
#define mii map<int,int>
#define pb push_back
#define ff first
#define ss second
#define FOR(i,t,n) for(int i=t;i<n;i++)
#define SCI(x)  scanf("%d",&x)
#define SCL(x) scanf("%lld",&x)

int main()
{

	int k;
	string s;
	cin>>k;
	cin>>s;
	if(s.length() <= k){
		cout<<s<<endl;
	}
	else{
		string ans = "";
		for(int i = 0;i<k;i++){
			ans += s[i];
		}
		ans =  ans +  "...";
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 3584
#One Quadrillion and One Dalmatians
alphabet = list('abcdefghijklmnopqrstuvwxyz')
N = int(input())-1

def shin26(N):
    if(int(N/26)!=0):
        return(shin26(int(N/26)-1)+alphabet[N%26])
    return alphabet[N%26]

print(shin26(N))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 0; long long ans = 0;
    long long mini = 1e9;
    for (int i = 0; i < n; i++) {
        ans += abs(a[i]);
        mini = min(mini, abs(a[i]));
        if (a[i] < 0) cnt++;
    }
    if (cnt & 1) {
        ans -= mini * 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll r;
	cin>>r;
	if(r<1200) cout<<"ABC"<<endl;
	else if(r<2800) cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int lens=s.size();
    int lent=t.size();
    int cnt = 0;
    for(int i=0,j=0;i<lens && j<lent;i++,j++){
         if(s[i] != t[j])
            cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	int n, m;
	cin >> n >> m;

	int d = __gcd(m, n);

	string s, t;
	cin >> s >> t;

	rep(i,0,d) if(s[n/d*i] != t[m/d*i]){
		puts("-1");
		return 0;
	}
	cout << 1LL*n/d*m << endl;
}

Measured memory_bytes: 640