akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!

t = ""
y = [0]*26
while True:
    try:
        n = input()
        m = str(n)
        m = m.lower()
        t += m
    except:
        break
for i in range(len(t)):
    x = ord(t[i])
    if x>96 and x<123:
        y[x-97] += 1
for i in range (97,123):
    print(chr(i), ":", y[i-97])


Measured memory_bytes: 5572
import java.io.*;
import java.util.*;

//solution classes here

public class Main {

    //main solution here

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int l = sc.nextInt();
        double len=l/(double)3;
        out.printf("%.12f",len*len*len);
        out.flush();
        out.close();
    }

    //solution functions here

    /*
     * ******************************************************************************************************************************
     * ******************************************************************************************************************************
     * ******************************************************************************************************************************
     * #########  #######  ######   ########  ##  ###   ##  ##    ##   #######  ##    ##   #######  ##   ##  #######   ########
     * ##    ###  ##       ##       ########  ##  ## #  ##   ##  ##    ##       ##    ##   ##       ##  ##   ##        ##    ##
     * ##    ###  #######  ######      ##     ##  ##  # ##     ##      #######  ##    ##   ##       ####     #######   ########
     * ##    ###  ##           ##      ##     ##  ##   ###     ##      ##       ##    ##   ##       ##  ##   ##        ##   ##
     * #########  #######  ######      ##     ##  ##    ##     ##      ##       ########   #######  ##   ##  #######   ##     ##
     *******************************************************************************************************************************
     *******************************************************************************************************************************
     *******************************************************************************************************************************
     */

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

/* *****************************************************************************************************************************
 * I'M NOT IN DANGER, I'M THE DANGER!!!
 * *****************************************************************************************************************************
 */

Measured memory_bytes: 21588
N  =  int(input())
A  =  list(map(int, input().split()))
A.sort(reverse = True)
d  =  {}
cnt = 0

for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
    
for i in range(N):
    if d[A[i]] == 0:
        continue
        
    d[A[i]] -= 1
    
    temp = 2 ** A[i].bit_length() - A[i]
    
    if temp in d and d[temp] > 0:
        cnt += 1
        d[temp]  -= 1
        
print(cnt)

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

using namespace std;
#define ll long long
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
const double pi=acos(-1);
const int mod=1e9+7;
const int maxn=1e6+10;

ll fa[maxn],s;
void getf(ll x)
{
    for(int i=2; i<=sqrt(x+0.5); i++)
    {
        if(x%i==0)
        {
            if(x/i==i)
                fa[s++]=i;
            else
            {
                fa[s++]=i;
                fa[s++]=x/i;
            }
        }
    }
    if(x!=1)
        fa[s++]=x;
}
int main()
{
    ll n;
    sll(n);
    s=0;
    getf(n);
    ll ans=0;
    for(int i=0; i<s; i++)
    {
        ll k=n;
        ll x=fa[i];
        while(k%x==0)
            k/=x;
        if(k%x==1)
            ans++;
    }
    s=0;
    getf(n-1);
    ans+=s;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()

    return n*(n-1)//2 + m*(m-1)//2


print(main())





Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
int count_bit(int a)
{
    n=0;
    while(a!=0)
    {
        if(a%2!=0)
        {
            n++;
        }
        a=a/2;
    }
}
int32_t main()
{
      int b;
      cin>>b;
      int a[b][b];
      int i,j,mo=1000000007;
      for(i=0;i<b;i++)
      {
          for(j=0;j<b;j++)
          {
              cin>>a[i][j];
          }
      }
      int x=1<<b;
      int dp[x];//
      for(i=0;i<x;i++)
      {
          dp[i]=0;
      }
      int co[x];
      for(i=0;i<x;i++)
      {
          count_bit(i);
          co[i]=n;
      }
      dp[0]=1;
      for(i=0;i<x;i++)
      {
          for(j=0;j<b;j++)
          {
              if(a[co[i]][j]==1&&((i&(1<<j))==0))
              {
                  dp[i|1<<j]=(dp[i|1<<j]+dp[i])%mo;
              }
          }
      }
      cout<<dp[x-1];
}



Measured memory_bytes: 33024
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	n := readInt()
	p := make([]int, n)
	for i := range p {
		p[i] = readInt()
	}

	var ans int
	for i := 1; i < n-1; i++ {
		if p[i] > p[i-1] && p[i] < p[i+1] {
			ans++
		} else if p[i] < p[i-1] && p[i] > p[i+1] {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int H, W, h, w;

int main(void)
{
	cin >> H >> W >> h >> w;
	
	if(H % h == 0 && W % w == 0){
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	int pval = W/w * H/h * 2;
	int nval = -pval * (w * h - 1) - 1;
	for(int y = 1; y <= H; y++){
		for(int x = 1; x <= W; x++){
			if(x % w == 0 && y % h == 0) cout << nval;
			else cout << pval;
			if(x != W) cout << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2048
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int R, C;
  while(cin>>R>>C,R){
	int ans = 0;
	vector<vector<bool>> senbei(R, vector<bool>(C, false));
	REP(y,R) REP(x,C){
	  int b; cin >> b;
	  senbei[y][x] = !b;
	}

	for(int bit=0;bit<(1<<R);++bit){
	  int sum = 0;
	  REP(i,C){
		int cnt = 0;
		REP(j,R)
		  if(((bit>>j&1) && !senbei[j][i])
			 || (!(bit>>j&1) && senbei[j][i])) ++cnt;
		sum += max(cnt, R-cnt);
	  }
	  ans = max(ans, sum);
	}
	cout << ans << endl;
  }
  
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        cout << "Possible";
    }else{
        cout << "Impossible";
    }
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<vector<int>> vec;
    vec = vector<vector<int>>(N, vector<int>(3,0));

    for(int i=0; i<N; i++){
        cin >> vec.at(i).at(0) >> vec.at(i).at(1) >> vec.at(i).at(2);
        reverse(vec.at(i).begin(), vec.at(i).end());
        reverse(vec.at(i).begin()+1, vec.at(i).end());
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
       
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            bool flag = true;
            int H = vec.at(0).at(0) + abs(i-vec.at(0).at(1)) + abs(j-vec.at(0).at(2));
            for(int k=1; k<N; k++){
                if(vec.at(k).at(0) == 0){
                    if(vec.at(k).at(0) + abs(i-vec.at(k).at(1)) + abs(j-vec.at(k).at(2)) < H){
                        flag = false;
                        break;
                    }
                }else{
                    if(vec.at(k).at(0) + abs(i-vec.at(k).at(1)) + abs(j-vec.at(k).at(2)) != H){
                        flag = false;
                        break;
                    }
                }
            }
            if(flag == true){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=1,aa[220000],ans=0;
pair<int,int> pp[220000];
string s,sa[220000],sb[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        if(aa[i]%2==0){
            cnt*=2;
        }
    }
    cout<<pow(3,n)-cnt<<endl;
}

Measured memory_bytes: 17880
#include <stdio.h>
int main(void){
    int a,n,x,i,j,k,l;
    
    for(a=0; a<100; a++){
        scanf("%d %d", &n, &x);
        if(n==0&&x==0){
            break;
        }
        l=0;
        for(i=1; i<n-1; i++){
            for(j=i+1; j<n; j++){
                for(k=j+1; k<n+1;k++){
                    if(i+j+k==x) l++;
                }
            }
        }
        printf("%d\n", l);
    }
    return 0;
}    


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

const int MOD = 1000000000 + 7;
const int MAX = 2000000;

long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long mod_comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    comb_init();

    long long ans = 0;
    for (int i = b; i <= w - 1; i++) {
        ans += mod_comb(i + h - a - 1, i) * mod_comb(w - i - 1 + a - 1, w - i - 1) % MOD;
        ans %= MOD;
    }
    
    cout << ans << endl;
}   

Measured memory_bytes: 47104
def resolve():
    n = int(input())
    xyh = list(list(map(int, input().split())) for _ in range(n))
    px, py, ph = [[x, y, h] for x, y, h in xyh if h > 0][0]
    for cx in range(101):
        for cy in range(101):
            H = ph + abs(cx - px) + abs(cy - py)
            if all(hi == max(H - abs(cx - xi) - abs(cy - yi), 0) for xi, yi, hi in xyh):
                return " ".join([str(cx), str(cy), str(H)])


if __name__ == "__main__":
    print(resolve())


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

int main(){
    int N=0;
    int R=0;
    
    cin>>N>>R;
    if(N>=10){
        cout<<R<<endl;
    }else{
        //R=RN-100*(10-K)
        cout<<(R+100*(10-N))<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) lps(i,0,n)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define FDST int hogehogehoge;cin>>hogehogehoge;

int main(){
  string s;
  cin>>s;
  int a[26];
  int count =0;
  lp(i,s.size()){
    if('a'<=s[i]&&s[i]<='z'){
      count++;
    }
  }
  lp(i,count){
    char c;
    int hoge;
    cin>>c>>hoge;
    a[c-'a']=hoge;
  }
  int stat=0;
  while(s.size()!=1){
    lp(i,s.size()){
      if(i==0) continue;
      if(s[i-1]=='['&&'a'<=s[i]&&s[i]<='z'&&s[i+3]==']'){
	string bef=s.substr(0,i-1);
	string cont=s.substr(i-1,5);
	string aft=s.substr(i+4,s.size()-i+5);
	int x,y;
	x=a[cont[1]-'a'];
	y=a[cont[3]-'a'];
	if(x==0){
	  a[cont[3]-'a']--;
	  cont=cont.substr(3,1);
	}
	else if(y==0){
	  a[cont[1]-'a']--;
	  cont=cont.substr(1,1);
	}
	else stat=1;
	s=bef+cont+aft;
	if(stat==1) break;
      }
    }
    if(stat==1) break;
  }
  if(stat==1||a[s[0]-'a']!=0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}



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

typedef unsigned long long hash_t;

const int maxn = 5e3 + 10;

char s[maxn];
int lcp[maxn][maxn];

int main() {
  int n; cin >> n;
  scanf("%s", s + 1);
  for (int i = n; i >= 1; i--)
    for (int j = n; j >= 1; j--) 
      lcp[i][j] = s[i] == s[j] ? lcp[i + 1][j + 1] + 1 : 0;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++)
      ans = max(ans, min(lcp[i][j], j - i));
  cout << ans << endl;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int N;cin >> N;
  vector<string> S(N);
  int count[4]={0};
  rep(i,N){
    string buffer;
    cin >> buffer;
    if(buffer=="AC"){
      count[0]++;
    }
    else if(buffer=="WA"){
      count[1]++;
    }
    else if(buffer=="TLE"){
      count[2]++;
    }
    else{
      count[3]++;
    }
  }

  cout << "AC x " << count[0] << endl;
  cout << "WA x " << count[1] << endl;
  cout << "TLE x " << count[2] << endl;
  cout << "RE x " << count[3] << endl;




  return 0;
}


Measured memory_bytes: 6432
///#pragma GCC optimize("Ofast")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
///#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
///#include<ext/pb_ds/assoc_container.hpp>
///#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll N = 10001;
const ll MOD = 1000000007;
const ll INF = LLONG_MAX;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'
#define PI acos(-1)

#define coutv(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define cinv(v) for(auto &it:v)cin>>it;


int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int tc=1,cs=0;
    ///cin>>tc;
    while(tc--)
    {
        ll n,m,i,s=0,a;
        cin>>n>>m;
        while(m--)
        {
            cin>>a;
            s+=a;
        }
        if(s>n)
            cout<<-1<<nl;
        else
            cout<<n-s<<nl;
    }
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>

#define true 1
#define false 0

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 10000000000000

//有向グラフ
//cが負の値も取りうることと、N^3はデカすぎることより
//bellman_ford法を用いる。
//今回は普通のベルマンではないが。
/*
  アルゴリズム概要
  N-1回実行する間に、頂点Nの値は少なくとも１回更新される。
  まずはこのN-1回の中で最大化される時を見つける
  次のN会の間に値が更新された時、閉路があるということなので、infになるかを調べる。
  次のN回の内（ループは最大でN）、さらに大きくなることがあれば、inf
*/

//正負を逆にして、一般的なbellman_fordを実装する。

long bellman_ford(int N, int M, int **edge){
  long *d=(long *)malloc(sizeof(long)*N);
  rep(i,N){
    d[i]=INF;
  }
  d[0]=0;

  rep(k,N-1){
    //int update=false;
    rep(j,M){
      if(d[edge[j][0]]!=INF && d[edge[j][0]]+edge[j][2]<d[edge[j][1]]){
        d[edge[j][1]]=d[edge[j][0]]+edge[j][2];
        //update=true;
      }
    }
  }
  // rep(i,N){
  //   printf("d[%d] = %d, ", i, d[i]);
  // }
  // printf("\n");
  //この時点で、d[N-1]にはN-1回の内での最小値が入っている。
  long record=d[N-1];

  rep(k,N){
    rep(j,M){
      if(d[edge[j][0]]+edge[j][2]<d[edge[j][1]]){
        d[edge[j][1]]=d[edge[j][0]]+edge[j][2];
      }
    }
  }
  // rep(i,N){
  //   printf("d[%d] = %d, ", i, d[i]);
  // }
  // printf("\n");

  if(record>d[N-1]){
    return INF*(-1);
  }
  else{
    return record;
  }
}




int main(){
  char buf[1024];
  int N,M;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &M);

  int *array=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    ;
  }

  int **edge=(int **)malloc(sizeof(int *)*M);
  rep(i,M){
    edge[i]=(int *)malloc(sizeof(int)*3);
  }
  rep(i,M){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%d %d %d", &edge[i][0], &edge[i][1], &edge[i][2]);
    edge[i][0]--;
    edge[i][1]--;
  }
  rep(i,M){
    edge[i][2]=edge[i][2]*(-1);
  }

  long longest=bellman_ford(N, M, edge)*(-1);

  if(longest==INF){
    printf("inf\n");
  }
  else{
    printf("%ld\n", longest);
  }

  return 0;
}


Measured memory_bytes: 256
def main43():
    data1 = input().split()
    hw1 = []
    for i in range(2):
        hw1.append(int(data1[i]))
    data2 = input().split()
    hw2 = []
    for i in range(2):
        hw2.append(int(data2[i]))
    result = (hw1[0] - hw2[0]) * (hw1[1] - hw2[1])
    print(result)

if __name__ == "__main__":
    main43()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int cost(int num1, int num2) {

	if (num1 > num2)return (num1 - num2)*(num1 - num2);
	else return (num2 - num1)*(num2 - num1);

}
int main() {

	string S;
	bool check = true;
	int b = -1, e = -1;

	cin >> S;

	if (S.size() == 2 && S[0] == S[1]) {

		b = 1;
		e = 2;

	}
	else {

		for (int i = 0; i < S.size() - 2; i++) {

			if (S[i] == S[i + 1]) {

				b = i + 1;
				e = i + 2;
				break;

			}
			if (S[i] == S[i + 2]) {

				b = i + 1;
				e = i + 3;
				break;

			}

		}

	}

	cout << b << " " << e << endl;

	return 0;
}

Measured memory_bytes: 512
<?php
while(true){
  $getNum = trim(fgets(STDIN));
  if ($getNum === '0'){
    break;
  }
    $list[] = $getNum;
}

foreach($list as $num){
  $search = array('7','6','5','4');
  $replace = array('9','8','7','5');
  $ans[] = str_replace($search,$replace,decoct($num));
}

$ans = implode("\n", $ans);
echo $ans;
?>

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

#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

int i, j;
string s;
int n;
ll dp[100001][13] = {0};
const ll mod = 1e9 + 7;

void solve() {
  string s;
  cin >> s;
  int l = s.size();
  int st = 0;
  int circle_pos = -1;
  bool has_r = false;
  for (i = 0; i < l; ++i) {
    if (s[i] == 'R') {
      if (circle_pos != -1) {
        for (j = st; j < circle_pos; ++j) cout << 0 << " ";
        int x = (i - st) / 2, y = (i - st - x);
        if ((circle_pos - st) % 2 == 1) {
          cout << x << " " << y << " ";
        } else {
          cout << y << " " << x << " ";
        }
        for (j = circle_pos + 2; j < i; ++j) cout << 0 << " ";
      }
      if (!has_r) {
        st = i;
        circle_pos = -1;
        has_r = true;
      }
    } else {
      has_r = false;
      if (circle_pos == -1) circle_pos = i - 1;
    }
  }
  for (j = st; j < circle_pos; ++j) cout << 0 << " ";
  int x = (l - st) / 2, y = (l - st - x);
  if ((circle_pos - st) % 2 == 1) {
    cout << x << " " << y << " ";
  } else {
    cout << y << " " << x << " ";
  }
  for (j = circle_pos + 2; j < l; ++j) cout << 0 << " ";
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <ll> v(n);
    generate(all(v),nxtl);
    vector <ll> prefix(n);
    prefix[0]=v[0];
    for(int i=1;i<n;i++)
        prefix[i]=prefix[i-1]+v[i];
    ll test=1e18;
    for(int i=0;i<n-1;i++)
    {
        ll val=abs(prefix[i]-prefix[n-1]+prefix[i]);
        if(val<test)
            test=val;
    }
    cout<<test<<endl;

    
    
    return 0;   
}




 
 


Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int n,a[15],s=0,s1=1,s2=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2==1)++s;
		s1=s1*3;
	}
	for(int i=1;i<=n-s;i++)
	s2*=2;
	printf("%d\n",s1-s2);
	return 0;
}

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

int main(){
  int i,j;
  char s[150];
  int n;
  int cnt = 0;

  scanf("%s", s);

  n = strlen(s);

  for(i = 0,j = n - 1;i < n/2;i++,j--){
    if(s[i] != s[j]) cnt++;
  }

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

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 62;

ll n;
string s_;
ll s[e5];
ll mem[e5];

ll dp[e5][4];
ll ans;

ll f(ll x){
  ll ret = 0;
  ll i = x-1;
  if(mem[i] < 2) return 0;
  return max(dp[i-mem[i]+1][3]+mem[i],dp[i-mem[i]+2][3]+mem[i]-1);
}

int main(){
  cin >> n;
  cin >> s_;
  for(ll i = 1;i <= n;i++){
    s[i] = s_[i-1]-'0';
  }
  ll k=0;
  for(ll i = 1;i <= n;i++){
    if(s[i]) k++;
    else mem[i] = k,k=0;
  }
  dp[0][0] = 1;
  for(ll i = 1;i <= n;i++){
    if(s[i]){
      if(dp[i-1][0]) dp[i][1] = max(dp[i][1],dp[i-1][0]);
      if(dp[i-1][2]) dp[i][1] = max(dp[i][1],dp[i-1][2]);
      if(dp[i-1][2]) dp[i][2] = max(dp[i][2],dp[i-1][2]+1);
      if(s[i-1] == 0) dp[i][0] = max(dp[i][0],f(i));
      if(dp[i-1][1]) dp[i][3] = max(dp[i][3],dp[i-1][1]);
      if(dp[i-1][3]) dp[i][3] = max(dp[i][3],dp[i-1][3]);
    }else{
      if(dp[i-1][0]) dp[i][0] = max(dp[i][0],dp[i-1][0]);
      if(dp[i-1][2]) dp[i][0] = max(dp[i][0],dp[i-1][2]);
      if(dp[i-1][1]) dp[i][2] = max(dp[i][2],dp[i-1][1]);
      if(dp[i-1][3]) dp[i][2] = max(dp[i][2],dp[i-1][3]);
    }
  }
  for(ll i = 0;i < 4;i++){
    ans = max(ans,dp[n][i]);
  }
  cout << ans-1 << endl;


}


Measured memory_bytes: 25476
#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.at(i);
  
  int A,B;
  A = 0;
  B = 0;
  bool turn = true;
  int m_cp = 0;
  for(int i=0; i<N; i++){
    int m_c = 0;
    for(int j=0; j<N; j++){      
      if(a.at(j) > m_c){
       	m_c = a.at(j);
        m_cp = j;
      }
    }
    if(turn){
      A += m_c;
      turn = false;
    }else{
      B += m_c;
      turn = true;
    }
    a.at(m_cp) = 0;
  }
  cout << A-B << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Node {
	public int id, degree, depth, height;
	public Node parent, sibling, left, right;
	Node(int id) {
		this.id = id;
		this.degree = 0;
		this.depth = 0;
		this.height = 0;
	}
	void setLeft(Node node) {
		left = node;
		left.parent = this;
		degree++;
	}
	void setRight(Node node) {
		right = node;
		right.parent = this;
		degree++;
	}
	/*
	void setSibling() {
		if (left != null && right != null) {
			left.sibling = right;
			right.sibling = left;
		}
	}
	void setDepth(int depth) {
		this.depth = depth;
		if (left != null) left.setDepth(depth + 1);
		if (right != null) right.setDepth(depth + 1);
	}
	void setHeight(int height) {
		if (height >= this.height) {
			this.height = height;
		}
		if (parent != null) parent.setHeight(this.height + 1);
	}
	*/
}

public class Main {
	public static void preorder(Node node, StringBuilder sb) {
		sb.append(" ").append(node.id);
		if (node.left != null) preorder(node.left, sb);
		if (node.right != null) preorder(node.right, sb);
	}
	public static void inorder(Node node, StringBuilder sb) {
		if (node.left != null) inorder(node.left, sb);
		sb.append(" ").append(node.id);
		if (node.right != null) inorder(node.right, sb);
	}
	public static void postorder(Node node, StringBuilder sb) {
		if (node.left != null) postorder(node.left, sb);
		if (node.right != null) postorder(node.right, sb);
		sb.append(" ").append(node.id);
	}
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node[] tree = new Node[n];
		for (int i = 0; i < n; i++) {
			tree[i] = new Node(i);
		}
		for (int i = 0; i < n; i++) {
			Node node = tree[scanner.nextInt()];
			int left = scanner.nextInt();
			if (left != -1) node.setLeft(tree[left]);
			int right = scanner.nextInt();
			if (right != -1) node.setRight(tree[right]);
			//node.setSibling();
		}
		Node root = null;
		for (int i = 0; i < n; i++) {
			if (tree[i].parent == null) {	
				root = tree[i];
				break;
			}
		}
		/*
		root.setDepth(0);
		for (int i = 0; i < n; i++) {
			tree[i].setHeight(0);
		}
		*/
		StringBuilder sb = new StringBuilder();
		System.out.println("Preorder");
		preorder(root, sb);
		System.out.println(sb);
		sb.setLength(0);
		System.out.println("Inorder");
		inorder(root, sb);
		System.out.println(sb);
		sb.setLength(0);
		System.out.println("Postorder");
		postorder(root, sb);
		System.out.println(sb);
	}
}

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

using namespace std;

// 1-indexed
template<typename T>
class BIT {
public:
    explicit BIT(int n) : N(calcN_(n)), mVal(calcN_(n)+1, 0) {}
    void add(int idx, T val){
        for(int x=idx;x<=N;x+=x&-x) mVal[x] += val;
    }
    T sum(int idx){
        T res = 0;
        for(int x=idx;x>0;x-=x&-x) res += mVal[x];
        return res;
    }
    void clean(){
        fill(mVal.begin(), mVal.end(), 0);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    const int N;
    vector<T> mVal; 
};

int main(){
    int N;
    while(cin >> N){
        vector<vector<int>> lines(N, vector<int>(3));
        for(auto& v : lines) cin >> v[0] >> v[1] >> v[2];
        double res[2];
        for(int i=0;i<2;i++){
            sort(lines.begin(), lines.end(), [](const vector<int>& a, const vector<int>& b){ return (double)a[0]/a[1] < (double)b[0]/b[1]; });
            double L = -1e10, R = 1e10;
            vector<int> v(N);
            auto val = [](const vector<int>& l, double x){ return ((double)l[2] - x * l[0])/l[1]; };
            for(int i=0;i<N;i++) v[i] = i;
            BIT<int> bit(N);
            long long thr = (N*(N-1LL)/2+1)/2;
            for(int _=0;_<100;_++){
                bit.clean();
                double mid = 0.5*(L+R);
                sort(v.begin(), v.end(), [&](int a, int b){ return val(lines[a], mid) < val(lines[b], mid); });
                long long cnt = 0;
                for(int i=N-1;i>=0;i--){
                    cnt += bit.sum(v[i]+1);
                    bit.add(v[i]+1, 1);
                }
                if(cnt < thr) L = mid;
                else R = mid;
            }
            res[i] = 0.5*(L+R);
            for(auto& v : lines) swap(v[0], v[1]);
        }
        printf("%.10lf %.10lf\n", res[0], res[1]);
    }
}

Measured memory_bytes: 2944
# https://atcoder.jp/contests/abc098/tasks/abc098_a

if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end

a=STDIN.gets.strip.split.map(&:to_i)
a.sort!
ans=0
ans+=a[2]-a[1]
a[0]+=a[2]-a[1]

debug ans
debug a

if (a[2]-a[0])%2==0
  ans+=(a[2]-a[0])/2
else
  ans+=1
  a[2]+=1
  ans+=(a[2]-a[0])/2
end
puts ans





Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 1000003
#define INF 1e9
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,i,j,k;
   	cin>>n>>m;
   	ld arr[n+5];
   	ld dp[n+2][n+2];
   	for(i=1;i<=n;i++) cin>>arr[i];
   	memset(dp,0,sizeof(dp));
   	dp[0][0]=1;
   	for(i=1;i<=n;i++){
   	  for(j=0;j<=i;j++){
   	  	    if(j==0) dp[i][j] = dp[i-1][j]*(1-arr[i]);
   	  	    else{
   	  	      dp[i][j] = dp[i-1][j]*(1-arr[i]) + dp[i-1][j-1]*(arr[i]);	
			}
		}	
	}
	ld ans =0;
	for(i = (n+1)/2 ; i<=n ;i++){
		ans += dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans;
 }

Measured memory_bytes: 141056
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

int n, a, b, x, y;
pair<pii, int> pt[100000];
int s;
vector<int> e[100000];
int deg[100000];
int bb[100001];

void conn(int u, int v)
{
    e[u].push_back(v);
    e[v].push_back(u);
}

void solve()
{
	memset(bb, 0, sizeof(bb));
    sort(pt, pt + n);
    rep(i, 0, n - 1)
    {
        int x = pt[i].X.X, y = pt[i].X.Y, v = pt[i].Y;
        pair<pii, int> pl = mp(mp(x + s, y - s + 1), 0), pu = mp(mp(x + s, y + s), n);
        int l = lower_bound(pt, pt + n, pl) - pt;
        int u = upper_bound(pt, pt + n, pu) - pt;
        if (u > l)
        {
            conn(v, pt[l].Y);
            deg[v] += u - l;
            deg[pt[l].Y] ++;
            bb[l] ++;
            bb[u - 1] --;
        }
    }
    rep(i, 0, n - 1)
    {
        if (bb[i] > 0)
        {
            deg[pt[i + 1].Y] += bb[i];
            conn(pt[i].Y, pt[i + 1].Y);
        }
        bb[i + 1] += bb[i];
    }
}

bool vis[100000];

int main()
{
    cin >> n >> a >> b;
    a --;
    b --;
    rep(i, 0, n - 1)
    {
        cin >> x >> y;
        pt[i].X = mp(x + y, x - y);
        pt[i].Y = i;
        deg[i] = 0;
    }
    s = max(abs(pt[a].X.X - pt[b].X.X), abs(pt[a].X.Y - pt[b].X.Y));
    solve();
    rep(i, 0, n - 1)pt[i].X = mp(pt[i].X.Y, -pt[i].X.X);
    solve();

    ll res = 0;
    queue<int> q;
    q.push(a);
    q.push(b);
    memset(vis, 0, sizeof(vis));
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        if (vis[v]) continue;
        vis[v] = true;
        res += deg[v];
        int nn = e[v].size() - 1;
        rep(i, 0, nn) q.push(e[v][i]);
    }

    cout << (res / 2) << endl;

    return 0;
}


Measured memory_bytes: 11136
from sys import stdin

def main():
    N,K = map(int,stdin.readline().split())
    arr = [int(x) for x in stdin.readline().split()]

    arr.sort()
    arr.reverse()
    res = 0
    for i in range(K,len(arr)):
        res +=arr[i]
    print(res)
main()


Measured memory_bytes: 26740
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<int> pos(N + 1);

    rep(i, 0, N) {
        var(int, x);
        --x;
        pos[x] = i;
    }

    int cnt = 1;
    int maxc = 1;
    rep(i, 1, N) {
        if (pos[i - 1] < pos[i]) {
            ++cnt;
        } else {
            chmax(maxc, cnt);
            cnt = 1;
        }
    }
    dump(cnt);
    chmax(maxc, cnt);

    print(N - maxc);
    return 0;
}


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

namespace AtCoderAbc160
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sSplit = s.Split();
            var x = int.Parse(sSplit[0]);
            var y = int.Parse(sSplit[1]);
            var a = int.Parse(sSplit[2]);
            var b = int.Parse(sSplit[3]);
            var c = int.Parse(sSplit[4]);

            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var q = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var problem = new Problem5();
            Console.WriteLine(problem.GetAnswer(x, y, a, b, c, p, q, r));
        }
    }

    public class Problem5
    {
        public long GetAnswer(int x, int y, int a, int b, int c, int[] p, int[] q, int[] r)
        {
            Array.Sort(p);
            Array.Sort(q);

            var list = new List<int>(a + b + c);
            for (int i = a - 1; i >= a - x && i >= 0; i--) { list.Add(p[i]); }
            for (int i = b - 1; i >= b - y && i >= 0; i--) { list.Add(q[i]); }
            list.AddRange(r);
            list.Sort((left, right) => right - left);

            return list.Take(x + y).Select(Convert.ToInt64).Sum();
        }
    }
}


Measured memory_bytes: 44088
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b;cin>>a>>b;
  if((a+b)%2==0)cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 55;

ll d[300][300] = {};
ll v[300][300] = {};
ll n;
void wf() {
	rep(k, 0, n)rep(i, 0, n)rep(j, 0, n) {
		if (d[i][j] > d[i][k] + d[k][j]) {
			cout << -1 << endl;
			exit(0);
		}
		if (i != k && i != j && j != k) {
			if (d[i][j] == d[i][k] + d[k][j]) {
				v[i][j] = true;
				v[j][i] = true;
				//d[i][j] = 0;
			}
		}
	}
}

int main() {
	cin >> n;

	rep(a, 0, n) {
		rep(b, 0, n) {
			ll p; cin >> p;
			d[a][b] = p;
			d[b][a] = p;
		}
	}

	wf();

	ll ans = 0;
	rep(i, 0, n)rep(j, 0, n) {
		if (!v[i][j]) {
			ans += d[i][j];
		}
	}

	cout << ans /2<< endl;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long int ll;
bool in_range(ll a,ll l,ll r){return (a>=l&&a<=r);}
using namespace std;
int32_t main(){
	#ifndef ONLINE_JUDGE
    	// for getting input from input.txt
    	freopen("input.txt", "r", stdin);
    	// for writing output to output.txt
    	freopen("output.txt", "w", stdout);
    	// for debug in error.txt
    	freopen("error.txt", "w", stderr);
	#endif
	int t = 1;
	while(t--) {
		ll x;
		cin >> x;
		if(in_range(x,400,599)) {
			cout << 8 << '\n';
		}
		if(in_range(x,600,799)) {
			cout << 7 << '\n';
		}
		if(in_range(x,800,999)) {
			cout << 6 << '\n';
		}
		if(in_range(x,1000,1199)) {
			cout << 5 << '\n';
		}
		if(in_range(x,1200,1399)) {
			cout << 4 << '\n';
		}
		if(in_range(x,1400,1599)) {
			cout << 3 << '\n';
		}
		if(in_range(x,1600,1799)) {
			cout << 2 << '\n';
		}
		if(in_range(x,1800,1999)) {
			cout << 1 << '\n';
		}
	}
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	//FastScannerクラス、普通の Scannerクラスだとメモリと時間を大幅に喰らうので高速化する内部クラス。
	
	public static void main(String[]args) {
		FastScanner sc = new FastScanner(System.in);

		int N = Integer.valueOf(sc.next());
		int[]A = new int [N];
		for(int i = 0;i<N;i++)A[i] = Integer.valueOf(sc.next());
		
		long []s = new long[N+2];
		
		s[1] = s[0]+(long)Math.abs(A[0]-0);//1
		for(int i = 1;i<N;i++) {//Nー1
			s[i+1] = s[i]+(long)Math.abs(A[i]-A[i-1]);
		}
		s[N+1] = s[N]+(long)Math.abs(0-A[N-1]);
		
		for(int i = 0;i<N;i++) {
			long goukei = 0;
			goukei+=s[N+1]-s[i+2];
			//System.out.print(goukei);
			//System.out.print(" ");
			goukei+=s[i];
			//System.out.println(s[i]);
			
			if(i==0) goukei+=(long)Math.abs(A[i+1]);
			else if(i==N-1)goukei+=(long)Math.abs(A[i-1]);
			else goukei+=(long)Math.abs(A[i+1]-A[i-1]);
			
			System.out.println(goukei);
		}
	}
	
	static class FastScanner {
		 
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
 
		public FastScanner(InputStream source) {
			in = source;
		}
 
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}
 
		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}
 
		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		}
 
		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 45036
#include <stdio.h>

int main()
{
	int a, b, c, s;
	scanf("%d %d %d", &a, &b, &c);
	if (a + b >= c - 1)
		s = b + c;
	if (a + b < c - 1)
		s = a + b + b + 1;
	printf("%d", s);
}

Measured memory_bytes: 128
alpha=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s=list(input())
s.sort()
cnt=0
for i in alpha:
    if i not in s:
        print(i)
        cnt+=1
        break
    else:
        continue
if cnt==0:
    print("None")

Measured memory_bytes: 47328
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long int
int ans=0;
int h[1<<21]={0};
int dp[1<<22][22];
main() {
    int n;
    cin>>n;
  	string s;
      cin>>s;
 	if(n>=3200)cout<<s<<endl;
 	else cout<<"red"<<endl;
  	return 0;
    double a[n+5];
    double ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    ans=a[1];
    for(int i=2;i<=n;i++){
        ans=(double(ans+a[i]))/2;
    }
    printf("%.10lf",ans);
    // cout<<ans<<endl;
}


Measured memory_bytes: 256