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

using namespace std;

int main()
{
    long long w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(2) << (w*h)/2.0 << " ";
    if(x==w/2&&y==h/2&&(w%2)==0&&(h%2)==0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N+1):
    s, e = int(str(i)[0]), int(str(i)[-1])
    c[s][e] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)

Measured memory_bytes: 3064
input_data = [int(i) for i in input().split(" ")]

ans = 0
for k1, v1 in enumerate(input_data):
    for k2, v2 in enumerate(input_data):
        for k3, v3 in enumerate(input_data):
            if k1 == k2 or k2 == k3 or k3 == k1:
                continue
            kou1 = int(str(v1) + str(v2))
            kou2 = v3
            if ans < kou1 + kou2:
                ans = kou1 + v3
print(ans)


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> as(q);
  for (auto &&a : as) {
    cin >> a;
    a--;
  }
  
  vector<int> bs(n, 0);
  for (auto &&a : as) {
    bs[a]++;
  }
  
  for (auto &&b : bs) {
    cout << (0 < k - q + b ? "Yes" : "No") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
S = input()

ans = 0
x = 0
for i in range(len(S)):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans, x)

print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  for(ll h = 1; h <= 3500; h++){
    for(ll n = 1; n <= 3500; n++){
      ll x = 4LL*h*n - N*n - N*h;
      if(4LL*h*n - N*n - N*h == 0) continue;
      ll y = N*h*n;
      if(y/x > 0 && y % x == 0LL){
        cout << h << ' ' << n << ' ' << y/x << endl;
        return 0;
      }
    }
  }
}

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

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
map<i_i, int> mp;
set<i_i> st;
vector<i_i> v;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    v.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
    }
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            int dx = v[i].first - v[j].first;
            int dy = v[i].second - v[j].second;
            if(dx < 0) {
                dx *= -1;
                dy *= -1;
            }
            if(dx == 0 && dy < 0) {
                dx *= -1;
                dy *= -1;
            }
            mp[{dx, dy}]++;
            st.insert({dx, dy});
        }
    }
    int ans = N;
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        chmin(ans, N - mp[*itr]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  	int a,b;
  	cin >> a >> b;
  	if(a > 0 && b > 0){
      cout << "Positive" << endl;
    }
  	else if(a <= 0 && b >= 0){
      cout << "Zero" << endl;
    }
  	else{
      if(abs(b - a) % 2 == 0){
        cout << "Negative" << endl;
      }
      else{
        cout << "Positive" << endl;
      }
    }
	return 0; 
}

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

string s;

int main(void){
	cin >> s;
	stack<char> st;
	rep(i, s.size()){
		if(s[i] == '0' || s[i] == '1') st.push(s[i]);
		else if(s[i] == 'B'){
			if(st.empty()) continue;
			else st.pop();
		}
	}
	string ans = "";
	while(!st.empty()){
		ans+=st.top();
		st.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n;//number of point
    int t;//base of temperature
    double a;//target of temperature

    cin >> n;
    cin >> t >> a;
    vector<long> pink;
//    long data[n]; //elevations
    long red;
    for(int i = 0; i < n; i++){
//        cin>>data[i];
        cin>>red;
        pink.push_back(red);
    }

//    double temp = t-0.006*data[0];
    double temp2 = t - 0.006*pink[0];
//    double gap = abs(a - temp);
    double gap2 = abs(a - temp2);
    int point = 0;
    for(int i = 0; i < n; i++){
//        temp = t - 0.006*data[i];
        temp2 = t - 0.006 * pink[i];
        /*if(gap > abs(a - temp)){
            point = i;
            gap = abs(a - temp);
        }*/
        if (gap2 > abs(a - temp2))
        {
            point = i;
            gap2 = abs(a - temp2);
        }
    }
    cout<<point+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n,d;
    int x[11][11];
    cin>>n>>d;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin>>x[i][j];
        }
        
    }

    int ans=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            int sum=0;
            for (int k = 0; k < d; k++)
            {
                sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            for (int k = 0; k < 1000; k++)
            {
                if (sum==k*k)
                {
                    ans++;
                    continue;
                }
                
            }
            
            
        }
        
    }
    
    
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Fri Apr 3 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int A = in.nextInt();
        int B = in.nextInt();
        if((A - B) % 2 == 0){
            println((A+B)/2);
        }
        else{
            println("IMPOSSIBLE");
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 23124
N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
	print(abs(A-B)//2)
	exit()

left = A-1
right = N-B

# left
a,b = 1, B-left-1
l = left + 1 + abs(b-a) // 2

# right
a,b = A+right+1, N
r = right + 1 + abs(b-a) // 2
print(min(l,r))

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


int dp[4][100001];
vector<int > a(100000+1),b(100000+1),c(100000+1);
int max_points(int x,int i)
{
    
    
    if(i==0)
    return 0;
    if(dp[x][i]!=-1)
    return dp[x][i];
    
    if(x==1)
    {
        return dp[x][i]=max(max_points(2,i-1),max_points(3,i-1))+a[i];
        
    }
    else if(x==2)
    {
        return dp[x][i]=max(max_points(1,i-1),max_points(3,i-1))+b[i];
    }
    else if(x==3)
    return dp[x][i]=max(max_points(1,i-1),max_points(2,i-1))+c[i];
  
    
}

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

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-') f = 1;ch = getchar();}
	while(isdigit(ch)) {x = x*10 + ch - '0';ch = getchar();}
	return f?-x:x;
}
const int N = 2e5+ 100;
int n,a[N],b[N],ans,res;
int main() 
{
	n = read();
	for(int i = 1;i <= n;i++) {
		a[i] = read();b[i] = read();
		if(a[i] == b[i]) res++;
		else res = 0;
		ans = max(res,ans);
	}
	if(ans >= 3) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

main() {
  ios::sync_with_stdio(false), cin.tie(0);
   
  int t = 1, n, m, i, j, k, u, to;
  // cin >> t;
  // int tc = t;
  while (t--) {
    // cout << "Case #" << tc - t << ": "; 
    cin >> n;
    int mn = n + 1, ans = 0;
    while(n--) {
      cin >> m;
      mn = min(mn, m);
      ans += mn == m;
    }
    cout << ans;
  }
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  cout<<s.substr(0,3)<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; i++) a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k-1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; i++) {
        int d = x % 10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    int a,b;
    cin>>a>>b;
    if(a>1 && b>1){
    if(a==b)cout<<"Draw";
    else if(a>b)cout<<"Alice";
    else cout<<"Bob";}else {
        if(a==1 && b>1)cout<<"Alice";
        else if(a>1 && b==1)cout<<"Bob";
        else if(a==1 && b==1)cout<<"Draw";
    }
}

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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
  
  if (op == "+") {
    cout << A+B << endl;
  }
  else {
    cout << A-B << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
for i in range(n):
    a,b,c = map(int, input().split())
    if c > a and c > b and a*a+b*b == c*c:
        print("YES")
    elif b > a and b> c and a*a+c*c == b*b:
        print("YES")
    elif a > b and a > c and b*b+c*c == a*a:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5596
#include <iostream>
#include <stdio.h>
#include <math.h>

#define DICE_SIZE 6

class Dice
{
private:
	int eyes[DICE_SIZE];
public:
	Dice(int e1, int e2, int e3, int e4, int e5, int e6)
	{
		eyes[0] = e1;
		eyes[1] = e2;
		eyes[2] = e3;
		eyes[3] = e4;
		eyes[4] = e5;
		eyes[5] = e6;
	}

	int GetTopEye()
	{
		return eyes[0];
	}

	void Roll(char c)
	{
		switch (c)
		{
		case 'E':
		case 'e':
			ToEest();
			break;

		case 'N':
		case 'n':
			ToNorth();
			break;

		case 'S':
		case 's':
			ToSouth();
			break;

		case 'W':
		case 'w':
			ToWest();
			break;

		default:
			break;
		}
	}

	void ToEest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[3];
		eyes[1] = temp[1];
		eyes[2] = temp[0];
		eyes[3] = temp[5];
		eyes[4] = temp[4];
		eyes[5] = temp[2];
	}

	void ToNorth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[1];
		eyes[1] = temp[5];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[0];
		eyes[5] = temp[4];
	}

	void ToSouth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[4];
		eyes[1] = temp[0];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[5];
		eyes[5] = temp[1];
	}
	
	void ToWest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[2];
		eyes[1] = temp[1];
		eyes[2] = temp[5];
		eyes[3] = temp[0];
		eyes[4] = temp[4];
		eyes[5] = temp[3];
	}
};

int main()
{
	int e1, e2, e3, e4, e5, e6;
	scanf("%d %d %d %d %d %d", &e1, &e2, &e3, &e4, &e5, &e6);
	Dice dice(e1, e2, e3, e4, e5, e6);

	getchar();

	char c;
	while ((c = getchar()) != '\n')
	{
		dice.Roll(c);
	}
	std::cout << dice.GetTopEye() << std::endl;
}


Measured memory_bytes: 3220
#include <stdio.h>

int main(){
	char S[11] = {0};
	scanf("%s",S);
	int i,j,len = 0;
	for(i = 0;i<10;i++){
		if(S[i] == 0)
			break;
		else{
			S[i] -= 0x30;
			len++;
		}
	}
	long long int sum = 0,tmp;
	for(i = 0;i< (1 << (len-1));i++){
		tmp = S[0];
		for(j = 0;j<len;j++){
			if(j == len-1 || i&(1<<j)){
				sum += tmp;
				tmp = 0;
				if(j == len-1)break;
			}
			tmp *= 10;
			tmp += S[j+1];
		}
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var KX = ReadInts();
            if (KX[0] * 500 >= KX[1])
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, tmp, r, x;
    cin >> A >> B;
    x = A * B;
    if(A < B){
        tmp = A;
        A = B;
        B = tmp;
    }

    r = A % B;
    while(r != 0){
        A = B;
        B = r;
        r = A % B;
    }
    cout << x/B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  ll sum = 0;
  int c = 0;
  int mi = INF;
  bool f = false;
  REP(i, n) {
    cin >> a[i];
    sum += abs(a[i]);
    mi = min(abs(a[i]), mi);

    if(a[i] < 0) c++;
    else if(a[i] == 0) f = true;
  }

  if(f) {
    cout << sum << endl;
  } else {
    if(c % 2 == 0) cout << sum << endl;
    else cout << (sum - (mi * 2)) << endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;string S;
    cin>>N>>S;
    int ans = 0;
    rep(i,10)rep(j,10)rep(k,10){
        int cnt = 0;
        rep(l,N){
            if      (cnt  == 0 && i == S[l]-'0')cnt++;
            else if (cnt  == 1 && j == S[l]-'0')cnt++;
            else if (cnt  == 2 && k == S[l]-'0')cnt++;
        }
        if(cnt==3)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(Math.max(0,A-2*B));
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999;
ll dp[MAX_N][3];

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

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

int main(void) {
	string s;
	cin >> s;
	int num = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
			num++;
		} else {
			num = 0;
		}
		ans = max(ans, num);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll a,b,w;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>w>>a>>b;
  if(a>b) swap(a,b);

  if(a+w>=b){
    cout << 0 <<endl;
    return 0 ;
  }else{
    cout << b-(a+w) <<endl;
  }
  return 0;
}

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

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int x, y, j;

            int[] player = new int[50];
            int buf = 0;

            while (true)
            {
                x = cin.GetInt();
                y = cin.GetInt();

                if (x == 0 && y == 0)
                    break;

                for (int i = 0; i < x; i++)
                    player[i] = 0;

                buf = y;

                j = 0;
                while (buf > 0 || !this.Check(x, player))
                {
                    if (buf == 0)
                    {
                        buf = player[j % x];
                        player[j % x] = 0;
                    }
                    else
                    {
                        player[j % x]++;
                        buf--;
                    }

                    j++;
                }

                Console.WriteLine("{0}", --j % x);
            }
        }

        private bool Check(int num, int[] player)
        {
            int count = player.Take(num).Count(x => x == 0);

            return count == num - 1;
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ', ',' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

Measured memory_bytes: 6032
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int ssn[10][10];
  int answer=0;
  REP(i,10) REP(j,10) cin >> ssn[i][j];
  REP(i,10) REP(j,10) REP(k,10) REP(l,10){
    bool flag=false;
    int d=ssn[ssn[ssn[ssn[0][i]][j]][k]][l];
    REP(e,10){
      if(i==e) continue;
      if(ssn[ssn[ssn[ssn[ssn[0][e]][j]][k]][l]][d]==0) flag=true;
    }
    REP(e,10){
      if(j==e) continue;
      if(ssn[ssn[ssn[ssn[ssn[0][i]][e]][k]][l]][d]==0) flag=true;\
    }
    REP(e,10){
      if(k==e) continue;
      if(ssn[ssn[ssn[ssn[ssn[0][i]][j]][e]][l]][d]==0) flag=true;
    }
    REP(e,10){
      if(l==e) continue;
      if(ssn[ssn[ssn[ssn[ssn[0][i]][j]][k]][e]][d]==0) flag=true;
    }
    REP(e,10){
      if(d==e) continue;
      if(ssn[ssn[ssn[ssn[ssn[0][i]][j]][k]][l]][e]==0) flag=true;
    }
    if(i!=j && ssn[ssn[ssn[ssn[ssn[0][j]][i]][k]][l]][d]==0) flag=true;
    if(j!=k && ssn[ssn[ssn[ssn[ssn[0][i]][k]][j]][l]][d]==0) flag=true;
    if(k!=l && ssn[ssn[ssn[ssn[ssn[0][i]][j]][l]][k]][d]==0) flag=true;
    if(l!=d && ssn[ssn[ssn[ssn[ssn[0][i]][j]][k]][d]][l]==0) flag=true;
    if(flag) ++answer;
  }
  cout << answer << endl;
  return 0;
}

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

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

int main(){
	int k;
	while(cin >> k, k){
		int sum = 0;
		rep(i,k*(k-1)/2){
			int c;
			cin >> c;
			sum += c;
		}
		cout << sum/(k-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=1e6+69;
const int mod = 1e9+7;
string s;
int n,m,k;
int a[MAXN];
int ans;
int fact[MAXN];
int luythua(int x, int y){
    if(y==0)return 1;
    if(y==1)return x;
    int k = luythua(x,y/2);
    if(y%2==0)return k*k%mod;
    return k*k%mod*x%mod;
}
int comb(int k, int n){
    int X =1,Y=1;
    for(int i=n;i>=n-k+1;i--){
        X*=i;
        X%=mod;
    }
    for(int i=k;i>=1;i--){
        Y*=i;
        Y%=mod;
    }
    return X*luythua(Y,mod-2)%mod;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    ans=luythua(2,n);
    ans-=1;
    m=min(n-m,m);    
    k=min(n-k,k);
    ans-=comb(m,n);
    if(ans<0)ans+=mod;
    ans-=comb(k,n);
    if(ans<0)ans+=mod;
    cout<<ans;
}


Measured memory_bytes: 2304
#include <stdio.h>

long long int max(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	return b;
}

int main(void) {
	int n, i;
	scanf("%d", &n);
	long long int a[n];
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	long long int dp[n][2];
	dp[0][0] = 0;
	dp[0][1] = -999999999999999999;
	for (i = 0; i < n; i++) {
		dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
		dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
	}
	printf("%lld\n", dp[n][0]);
	return 0;
}


Measured memory_bytes: 2560
S = list(input())
h  = S[0]+S[1]
l  = S[2]+S[3]
h,l = int(h),int(l)
if l<=12 and l>0:
    if h<=12 and h>0:
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif h<=12 and h>0:
    print('MMYY')
else:
    print('NA') 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll x;
	cin>>x;
	cout<<x+x*x+x*x*x;
	return 0;
}

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

template<class T>
map<T,int> prime_factor(T n){
    map<T,int> ret;
    if(n <= 0){
        cout << "Prime_factor Error" << "\n";
        return ret;
    }
    for(long long i = 2; i*i <= n; ++i){
        while(n%i== 0){
            ++ret[i];
            n /= i;
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

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

    ll n; cin >> n;
    map<ll,int> factor = prime_factor(n);
    int ans = 0;
    for(auto i : factor){
        int tmp = 1;
        int vtmp = i.second;
        while(tmp <= vtmp){
            vtmp -= tmp;
            ans++;
            tmp++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    long long ans = 0;
    for(int i=0; i< (1<<(s.size()-1)); ++i)
    {
        long long t = 0;
        for(int j=0; j<s.size()-1; ++j)
        {
            t = (10*t+s[j]-'0');
            if(i&(1<<j))
            {
                ans += t;
                t = 0;
            }
        }
        ans += 10*t+s[s.size()-1] - '0';
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#define c(a,b)F[a]%M*p(F[a-b],M-2)%M*p(F[b],M-2)%M
long M=998244353,a,b,k,F[3<<17]={1},i,j,s;long p(a,b)long a;{return b?p(a*a%M,b/2)*(b%2?a:1)%M:1;}main(n){for(scanf("%d%d%d%ld",&n,&a,&b,&k);j++<n;)F[j]=j*F[j-1]%M;for(;i<=n;i+=j<0|j>n|a*i+b*j-k||(s=(s+c(n,i)*c(n,j))%M))j=(k-a*i)/b;printf("%d",s);}

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

using namespace std;
using ll = long long;
using edge = struct { int to; ll cost; };

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)

long long combination[10001][10001];

//initC(int n);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    string s;
    cin >> s;
    set<char> ss;
    REP(i, 3) ss.insert(s[i]);
    if(ss.size() == 3) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

int main()
{
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

#define lim5 100002
#define lim9 1000000002

int main(){
	int n, cnt = 0, max = 0;
	ll h[lim5];

	cin >> n;
	rep(i, n) cin >> h[i];

	rep(i, n - 1) {
		if (h[i] >= h[i + 1]) ++cnt;
		else cnt = 0;
		if (cnt > max) max = cnt;
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 1024
/**********************************************
*   UPDATE CONDITION & OVERFLOW CONDITION     *
**********************************************/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t; while(t--)
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const long long int inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    int a[5];
    get(a,5);
    f(i,0,5)
    {
        if(a[i] == 0)
        {
            cout << i+1;
            return 0;
        }
    }
}



Measured memory_bytes: 3592
N, M = gets.split(' ').map(&:to_i)
cakes = []
N.times do
  cakes.push(gets.split(' ').map(&:to_i))
end
 
cand = []
[1, -1].repeated_permutation(3) do |sign|
  ncakes = cakes.collect{|x, y, z| x * sign[0] + y * sign[1] + z * sign[2]}
  ncakes.sort!
  ncakes.reverse!
  cand.push(ncakes[0..(M - 1)].inject(:+))
end

if M >= 1
  puts cand.max
else
  puts 0
end

#他の方の方法をメモ代わりに残してます

Measured memory_bytes: 3960
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a ,b,c,i;
    cin >> a >> b;
   
    for( i=1; a!=0 ||b!=0; i++)
    {
     
      if(a>b)
       
      cout << b << " " <<a << endl;
       else 
       cout << a << " " <<b << endl;
   
    cin >> a >> b;
}

    
    
}


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

using namespace std;

signed main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (i & 1 and x & 1) {
      ++ans;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), x(M), y(M), c(M);
  for (int i = 0; i < A; i++) cin >> a.at(i);
  for (int i = 0; i < B; i++) cin >> b.at(i);
  for (int i = 0; i < M; i++) cin >> x.at(i) >> y.at(i) >> c.at(i);
  for (int i = 0; i < M; i++) {
    x.at(i)--;
    y.at(i)--;
  }
  
  int ma = 1000000, mb = 1000000;
  for (int i = 0; i < A; i++) ma = min(ma, a.at(i));
  for (int i = 0; i < B; i++) mb = min(mb, b.at(i));
  
  int ans = ma + mb;
  for (int i = 0; i < M; i++) {
    ans = min(ans, a.at(x.at(i)) + b.at(y.at(i)) - c.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
H, W = [int(i) for i in input().split()]
SS = [input() for _ in range(H)]

def get(lst, i, default=None):
  try:
    return lst[i]
  except IndexError:
    return default

for i in range(H):
  for j in range(W):
    s = SS[i][j]
    if s == '#':
      if '#' not in [get(get(SS, i-1, []), j), get(get(SS, i, []), j-1), get(get(SS, i+1, []), j), get(get(SS, i, []), j+1)]:
        print('No')
        import sys
        sys.exit()

print('Yes')


Measured memory_bytes: 9092
package main

import "fmt"

func main() {
	var s string
	var max, tmp int = 0, 0
	fmt.Scan(&s)
	for _, c := range s {
		switch string(c) {
		case "A", "C", "G", "T":
			tmp++
		default:
			if max < tmp {
				max = tmp
				tmp = 0
			}
		}
	}
	if max < tmp {
		max = tmp
		tmp = 0
	}
	fmt.Println(max)
}


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

void solve() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 == m2 && d1 + 1 == d2)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n, q;
	cin >> n >> q;
	queue<pair<string, int> > Q;
	string name;
	int time;
	rep(i, n){
		cin >> name >> time;
		Q.push(make_pair(name, time));
	}

	int decV;
	int sum = 0;
	while( !Q.empty() ){
		decV = min(q, Q.front().second);
		Q.front().second -= decV;
		sum += decV;
		if(Q.front().second == 0){
			cout << Q.front().first << ' ' << sum << endl;
			Q.pop();
		}
		else {
			Q.push(Q.front());
			Q.pop();
		}
	}

	return 0;
}



Measured memory_bytes: 6296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i;
        String [] data = new String[3];
        int [] abc = new int[3];
        for(i=0;i<3;i++){
            data[i]=scan.next();
            abc[i]=new Integer(data[i]);
        }
        String result=check(abc);
        if(!(result=="Yes")) result="No";
        System.out.println(result);
    }
    
    public static String check(int [] abc){
        String result = "";
        if((abc[0] < abc[1]) && (abc[1] < abc[2])) result = "Yes";
        
        return result;
    }
    
}

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

const int N = (1e5) + 5;
int cnt[N];

int main() { // claudio van
  int n, k, q; scanf("%d %d %d", &n, &k, &q);
  for (int i = 0; i < q; ++i) {
    int a; scanf("%d", &a);
    cnt[a]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (k - q + cnt[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

public class Main {

	private static Scanner in;

    private static int n;
    private static int[] a;
    private static long[][] dp;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        n = in.nextInt();
        a = new int[n];
        for(int i=0; i<n; i++) a[i] = in.nextInt();

        dp = new long[n][n];

        for(int i=0; i<n; i++) {
            Arrays.fill(dp[i], -1);
        }

        System.out.println(solve(0, n-1));
        
    }

    private static long solve(int left, int right) {
        if (left==right) return 0;

        if (dp[left][right]!=-1) return dp[left][right];

        long ans = (long)1e15;

        long cost = 0;
        for(int i=left; i<=right; i++) cost+=a[i];

        for(int k=left; k<right; k++) {
            //left:k and k+1:right are combined seperately
            ans = Math.min(ans, cost+solve(left, k)+solve(k+1, right));
        }

        return dp[left][right]=ans;
    }
    
    
}


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

int main()
{
  long N, C, K;
  std::cin >> N >> C >> K;
  long T[N];
  for ( int i = 0; i < N; i++ ) std::cin >> T[i];
  std::sort(T, T+N);

  long deadline = T[0] + K;

  long n_buses = 1; 

  for ( long i = 0, cnt = 0; i < N; i++ ) {
    if ( T[i] <= deadline && cnt < C ) cnt++;
    else {
      cnt = 0;
      n_buses++;
      deadline = T[i] + K;
      i--;
    }
  }

  std::cout << n_buses << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
        int i, k, N, tmp, flag, cnt;
        int A[10000];

        scanf("%d", &N);
        for(i=0; i<N; i++){
                scanf("%d", &A[i]);
        }
        cnt = 0;
        flag = 1;
        while(flag){
                flag = 0;
                for(i=N-1; i>0; i--){
                        if(A[i] < A[i-1]){
                                tmp = A[i];
                                A[i] = A[i-1];
                                A[i-1] = tmp;
                                flag = 1;
                                cnt++;
                        }
                }
        }
        for(i=0; i<N-1; i++){
                printf("%d ", A[i]);
        }
        printf("%d\n", A[i]);
        printf("%d\n", cnt);

        return 0;
}

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

int a,l,r;

signed main()
{
	cin>>a>>l>>r;
	for (int i=l;i<=r;i++)
	{
		if (i%a==0)  return cout<<"OK"<<endl,0;
	}
	cout<<"NG"<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
l,r = map(int,input().split())
ans = 2018
flag = 0
for i in range(l,r):
    for j in range(l+1,r+1):
        ans = min(ans,i*j%2019)
        if ans == 0:
            flag = 1
            break
    if flag:
        break
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(void) {
    char c;
    int count[26] = {0}, i;
    while (1) {
        if (scanf("%c", &c) == EOF)
            break;
        if ('a' <= c && c <= 'z')
            count[c-'a']++;
        else if ('A' <= c && c <= 'Z')
            count[c-'A']++;
    }
    for (i = 0; i < 26; i++) {
        cout << (char)(i + 'a') << " : " << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = input()
    if N == N[::-1]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    dp = [[0]*(s+1) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(n+1):
        ai = a[i-1]
        for j in range(s+1):
            dp[i][j] += dp[i-1][j]*2
            if j >= ai:
                dp[i][j] += dp[i-1][j-ai]
            dp[i][j] %= mod
    print(dp[n][s])
            

if __name__ == "__main__":
    main()

Measured memory_bytes: 144560
#include <bits/stdc++.h>
using namespace std;
long long dp[3001][3001];
long long a[3001];
long long game(int i, int j,  int c){
   // cout<<i<<" "<<j<<" "<<x<<" "<<y<<endl;
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    long long ans;
    if(i > j){
      //  cout<<x<<" "<<y<<"%%%%5"<<endl;
        return 0;
    }
    else{
        if(c%2 == 0){
            //if(i == j)return (x + a[i] - y);
             ans = max(game(i + 1, j, c + 1) + a[i], game(i, j-1,  c + 1) + a[j]);
         //    cout<<game(i + 1, j, x + a[i], y, c + 1)<<"****"<<game(i, j-1, x + a[j], y, c + 1)<<endl;
        }else{
            //if(i == j)return (x - y - a[i]);
             ans = min(game(i + 1, j,  c+1) - a[i], game(i, j -1,  c + 1) - a[j]);
         //    cout<<game(i + 1, j, x , y + a[i], c + 1)<<"****"<<game(i, j-1, x , y + a[j], c + 1)<<endl;
        }
    }
  //  cout<<i<<"#"<<j<<"#"<<c<<"#"<<ans<<endl;
    dp[i][j] = ans;
    return ans;
}

int main(){
    long long mod = 1000000007;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    //vector<int> a(n, 0);
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout<<game(0, n-1,  0)<<endl;
    return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
long id[100009];
map<long,long> q;
vector<pair<long,long> >v;
void init(long n)
{
    rep(i,0,n+1){
        id[i]=i;
        q[i]=1;
    }
}
long root(long x)
{
    while(id[x]!=x)
        x=id[x];
    return x;
}
void Union(long x,long y)
{
    id[root(x)]=id[root(y)];
}
long long CC(long long x){
    return ((x)*(x-1))/2;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long n,m,x,y;
    long long c=0,a,b;
    vector<long long> ans;
    cin>>n>>m;
    ans.push_back(CC(n));
    //cout<<"0\n";
    init(n);
    rep(i,0,m)
    {
        cin>>x>>y;
        v.push_back({x,y});
    }
    for(long i=m-1;i>=0;i--)
    {
        //cout<<v[i].first<<" "<<v[i].second<<"\n";
        x=v[i].first;
        y=v[i].second;
        if(root(x)!=root(y))
        {
            a=q[root(x)];
            b=q[root(y)];
            q[root(x)]+=b;
            q[root(y)]+=a;
            c-=CC(a);
            c-=CC(b);
            c+=CC(a+b);
        }
        ans.push_back(CC(n)-c);
        //cout<<c<<"\n";
        Union(x,y);
        id[x]=root(x);
        id[y]=root(y);
        //rep(j,1,n+1)
        //    cout<<j<<" "<<id[j]<<"\n";
        //cout<<"\n";
    }
    //cout<<"\n";
    for(long i=m-1;i>=0;--i)
        cout<<ans[i]<<"\n";
}

Measured memory_bytes: 11764
n = int(input())

X = []
Y = []
for i in range(n):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X.sort()
Y.sort()

edge = []
for i in range(n):
    x, a = X[i]
    y, s = Y[i]
    if i > 0:
        xb, b = X[i-1]
        ty, t = Y[i-1]
        edge.append((a, b, abs(x - xb)))
        edge.append((s, t, abs(y - ty)))
    if i + 1 < n:
        xb, b = X[i+1]
        ty, t = Y[i+1]
        edge.append((a, b, abs(x - xb)))
        edge.append((s, t, abs(y - ty)))

class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def same(self, x, y):
        xp = self.find(x)
        yp = self.find(y)
        return xp == yp

    def union(self, x, y):
        xp = self.find(x)
        yp = self.find(y)
        if xp != yp:
            if self.table[xp] < self.table[yp]:
                self.table[xp] += self.table[yp]
                self.table[yp] = xp
            else:
                self.table[yp] += self.table[xp]
                self.table[xp] = yp

u = Unionfind(n)
ans = 0
for a, b, c in sorted(edge, key = lambda x: x[2]):
    if not u.same(a, b):
        ans += c
        u.union(a, b)
print(ans)

Measured memory_bytes: 124500
import itertools

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

ans = []

for s in itertools.product(range(2), repeat=N):

    li = [0 for _ in range(M)]
    cum = 0
    for i, v in enumerate(s):
        if v == 1:
            ca = CA[i]
            cum += ca[0]

            for j, x in enumerate(ca[1:]):
                li[j] += x

        q = [p >= X for p in li]
        if all(q):
            ans.append(cum)

print(min(ans) if ans else -1)


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

int main() {
	long long over=0;
	long long less2=0;
	
	long long N;
	cin>>N;
	
	long long a[N],b[N];
	for(int i=0; i<N; i++){
		cin >> a[i];
		
	}
	for(int i=0; i<N; i++){
		cin >> b[i];
	}

	

	for(int i=0; i<N; i++){
		if(a[i]>b[i]){
			over+=a[i]-b[i];
		}else if(a[i]<b[i]){
			less2+=(b[i]-a[i])/2;
		}
	}
	
	
	if(over<=less2){
		cout << "Yes"<<endl;
	}else{
		cout << "No"<<endl;
	}
	
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int wayN, wayM;
  if (N < 2) {
    wayN = 0;
  }
  if (M < 2) {
    wayM = 0;
  }
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

Measured memory_bytes: 256