akhauriyash/Code-Regression huggingface dataset:
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int sum = 0;
            if(s[0] == t[0])
            {
                sum++;
            }
            if(s[1] == t[1])
            {
                sum++;
            }
            if(s[2] == t[2])
            {
                sum++;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<(n);++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
    lli n;cin>>n;
    lli arr[n];
    lli last=0;
    fr(i,n){
        cin>>arr[i];
        if(arr[i]==last+1){
            last++;
        }
    }
    if(last==0){
        cout<<-1<<endl;
    }else{
        cout<<n-last<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    pre();lli _t=1;//cin>>_t;
    for(lli i=1;i<=_t;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
using namespace std;
int main() {
  long double a,b,x;
  long double ans;
  cin >> a >> b >> x;
  x /= a;
  if(x>=(a*b)/2) {
    ans = atan2(2*(a*b-x)/a,a);
  }
  else {
    ans = atan2(b,2*x/b);
  }
  ans *= (long double)360/(2*M_PI);
  printf("%.10llf\n",ans);
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int d1 = abs(a1-a2), d2 = abs(a2-a3), d3 = abs(a3-a1);
  vector<int> d = {d1, d2, d3};
  sort(d.begin(), d.end());
  cout << d[0] + d[1] << endl;
}


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

namespace aizu1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] s = str.Split(' ');
            Stack<int> stack = new Stack<int>();
            
            for(int i=0;i<s.Length;i++)
            {
                if(s[i]=="+"||s[i]=="-"||s[i]=="/"||s[i]=="*")
                {
                    int a = stack.Pop();
                    int b = stack.Pop();

                    switch (s[i])
                    {
                        case "+":
                            stack.Push(a+b);
                            break;
                        case "-":
                            stack.Push(b - a);
                            break;
                        case "*":
                            stack.Push(b * a);
                            break;
                        case "/":
                            stack.Push(b / a);
                            break;
                    }
                }
                else stack.Push(int.Parse(s[i]));
            }

            Console.WriteLine(stack.Pop());
        }
    }
}

Measured memory_bytes: 10092
#include <bits/stdc++.h>
using namespace std;
vector<string> C;
vector<vector<int>> memo;
vector<vector<int>> C1;
int pp;
int g(int p, int q) {
	if (C1[p][q] >= 0) return C1[p][q];
	if (p == 0 || q == 0) return C1[p][q] = 0;
	int rr = g(p-1, q-1);
	if (C[p-1][pp-1] == C[q-1][pp]) ++ rr;
	return C1[p][q] = rr;
}
int f(int p, int q) {
	if (p == 0 && q == 0) return 0;
	if (memo[p][q] >= 0) return memo[p][q];
	int rr = 1<<30;
	if (p) rr = min(rr, f(p-1, q)+g(p,q));
	if (q) rr = min(rr, f(p, q-1)+g(p,q));
	return memo[p][q] = rr;
}
int main() {
	int H, W;
	cin >> H >> W;
	C.resize(H);
	for (auto& x : C) cin >> x;
	int r = 0;
	for (pp = 1; pp < W; ++ pp) {
		C1 = vector<vector<int>>(H+1, vector<int>(H+1, -1));
		memo = vector<vector<int>>(H+1, vector<int>(H+1, -1));
		r += f(H,H);
	}
	cout << r << endl;
}


Measured memory_bytes: 1596
n = int(input())
if n >= 900:
    a = 100
    n -= 900
else:
    a = 900
    n -= 100
if n >= 90:
    a += 10
    n -= 90
else:
    a += 90
    n -= 10
if n == 9:
    a += 1
else:
    a += 9

print(a)

Measured memory_bytes: 2940
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

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

    vector<vector<int>> dp(SZ(s) + 1, vector<int>(SZ(t) + 1));
    rep(i, SZ(s) + 1){
        rep(j, SZ(t) + 1){
            if(i + 1 <= SZ(s)){
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            }
            if(j + 1 <= SZ(t)){
                dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
            }
            if(i + 1 <= SZ(s) && j + 1 <= SZ(t)){
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + (s[i] == t[j]));
            }
        }
    }

    int x = SZ(s);
    int y = SZ(t);
    string ans;
    while(x > 0 && y > 0){
        if(s[x-1] == t[y-1]){
            ans.push_back(s[x-1]);
            x--;
            y--;
            continue;
        }
        if(dp[x][y] == dp[x-1][y]){
            x--;
            continue;
        }
        y--;
    }
    reverse(ALL(ans));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 70784
s=input()
youbi=["SUN","MON","TUE","WED","THU","FRI","SAT" ]

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

Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

typedef complex<double> P;

const double eps = 1e-8;

double heron(P p1, P p2, P p3) {
    double x = abs(p2 - p1), y = abs(p3 - p2), z = abs(p1 - p3);
    double s = (x + y + z) / 2.0;
    return sqrt(s * (s - x) * (s - y) * (s - z));
}

int main() {
    P p[4];
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
          &p[0].real(), &p[0].imag(), &p[1].real(), &p[1].imag(),
                &p[2].real(), &p[2].imag(), &p[3].real(), &p[3].imag()) != EOF) {
        if (abs(heron(p[0], p[1], p[2]) + heron(p[0], p[2], p[3])
                - heron(p[1], p[2], p[3]) - heron(p[1], p[3], p[0])) < eps) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1240
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var rc=Arr.shift().split(" ").map(Number);
   var r=rc[0];
   var c=rc[1];
   if(r==0 && c==0)break;
   console.log((r%2==1 && c%2==1)?"no":"yes");
}

Measured memory_bytes: 9264
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
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 [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# N=pb+r

def main():
  n,k=LI()
  ans=0

  for b in range(1,n+1):
    if b<k:
      continue

    ans+=(n//b)*(b-k)+max(0,n%b-k+1)

  if k==0:
    ans-=n
  return ans

# main()
print(main())


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

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> a( H+2 );
	a.at( 0 ) = string( W, '#' );
	a.at( H+1 ) = string( W, '#' );

	for( int i = 0; i < H; ++i ) {
		cin >> a.at( i+1 );
	}

	for( int i = 0; i < H+2; ++i ) {
		cout << '#' << a.at(i) << '#' << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A;
    cin >> A;
    string ans;
    if(A<1200)  ans="ABC";
    else if(A<2800) ans="ARC";
    else ans="AGC";
    cout << ans << endl; 

   return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	int a, b, k[100005], ans = 0;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
		if (k[i] >= b) { ++ans; }
	}

	cout << ans << endl;
}

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

int main()
{
  int n;
  int SCORE_A, SCORE_B;
  while (1) {
    scanf("%d", &n);
    if (!n) return 0;
    SCORE_A = SCORE_B = 0;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        SCORE_A += a;
        SCORE_B += b;
      }
      else (a > b ? SCORE_A : SCORE_B) += (a + b);
    }
    cout << SCORE_A << " " << SCORE_B << endl;
  }
}



Measured memory_bytes: 3120
import sys
import itertools
flatten = itertools.chain.from_iterable
input = sys.stdin.readline


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N, K = inpl()

ss = list(range(0, N + 3))
for i in range(1, N + 3):
    ss[i] += ss[i - 1]

mod = 10**9 + 7

ans = 0
for k in range(K, N + 2):
    L = ss[k]
    R = ss[N + 1] - ss[N + 1 - k]
    ans += (R - L + 1)
    ans %= mod

print(ans)


Measured memory_bytes: 19400
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Character, Set<String>> map = new HashMap<>();
		for(int i =0; i < n; i++) {
			String s = sc.next();
			if(!s.matches("^[MARCH].*")) continue;
			char c = s.charAt(0);
			if(!map.containsKey(c)) map.put(c, new HashSet<String>());
			map.get(c).add(s);
		}
		if(map.size() < 3) {
			System.out.println(0);
			return;
		}
		List<Set<String>> list = new ArrayList<>(map.values());
		long sum = 0;
		for(int i = 0;i < list.size(); i++){
			for(int j = i+1; j < list.size(); j++){
				for(int k = j+1; k < list.size(); k++){
					long l = (long)list.get(i).size() * (long)list.get(j).size() * (long)list.get(k).size();
					sum += l;
				}
			}
		}
		System.out.println(sum);

	}
}


Measured memory_bytes: 72100
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
typedef long long ll;
#define FOR(i,n) for(int i=0;i<n;i++)

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

  cout << b/ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s;
  cin >> s;

  rep(i,(s.size()+1)/2) cout << s[2*i];

  cout << endl;
  return 0;
} 

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

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++)
		cin >> a[i];
	int i=0, num=0;
	vector<int> baq(n);
	baq[i]++;
	while(true){
		num++;
		i=a[i]-1;
		baq[i]++;
		if(i==1){
			cout << num << endl;
			break;
		}
		else if(baq[i]==2){
			cout << -1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(){
    
    int N,a[10000] ,count = 0;
    
    scanf("%d",&N);
    for(int i = 0;i<N;i++)
    {
        scanf("%d",&a[i]);
        
        while(a[i]%2 == 0)
            {count++;
            a[i] /=2 ;
            }
    }
    
    
    printf("%d",count);
    
    return 0;
}        

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

int main() {
  int w, n;
  cin >> w >> n;
  int ans[n];

  for (int i=0; i<=w; i++)
    ans[i] = i;
  for (int i=0; i<n; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(ans[a], ans[b]);
  }
  for (int i=1; i<=w; i++)
    cout << ans[i] << endl;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str[101];

	int n,l;
	cin >> n >> l;
	for(int i=0 ; i<n ; i++)
	{
		cin >> str[i];
	}

	for(int i=0 ; i<n ; i++)
	{
		for(int j=i+1 ; j<n ; j++)
		{
			if(str[i] > str[j])
				swap(str[i] , str[j]);
		}
	}

	for(int i=0 ; i<n ; i++)
		cout << str[i];

	return 0;
}

Measured memory_bytes: 256
import sys
from math import cos, radians, pi, sqrt

#3 4 9 0

input = input().split()

A = int(input[0])
B = int(input[1])
H = int(input[2])
M = int(input[3])

rad = 2*pi*(H/12.0+(M/60.0)/12.0-M/60.0)
out = sqrt((pow(A,2)+pow(B,2))-(2*A*B*cos(rad)))

print(out)

Measured memory_bytes: 9524
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x %= p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll po(ll base, ll powerRaised)
{
  if (powerRaised != 0)
    return (base * po(base, powerRaised - 1));
  else
    return 1;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    cout << "x";

  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

n, x, y = gets.split.map(&:to_i)

a = Array.new(n - 1) { 0 }

(1..(n - 1)).each do |i|
  ((i + 1)..n).each do |j|
    l = [j - i, (x - i).abs + 1 + (y - j).abs, (y - i).abs + 1 + (x - j).abs].min
    a[l - 1] += 1
  end
end
puts a


Measured memory_bytes: 1788
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int t = sc.nextInt();
                for(int i = 0 ; i < t ; i++){
                        int n = sc.nextInt();
                        int k = sc.nextInt();
                        int[] x = new int[n];
                        for(int j = 0; j < n ; j++){
                                x[j] = sc.nextInt();
                        }   
                        int[] d = new int[n-1];
                        for(int j = 0 ; j < n-1; j++){
                                d[j] = x[j+1]-x[j];
                        }   
                        Arrays.sort(d);
                        int sum = 0;
                        for(int j = 0; j < n-k; j++){
                                sum += d[j];
                        }   
                        System.out.println(sum);
                }   
                sc.close();
        }   
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);++i)

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
int main(void){
  int A,B;
  cin >> A >> B;
  int ans;
  ans=A*B;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class v:
    def __init__(self, f):
        self.f = f
        self.v = None
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N, M = read_values()
    print((N + M) * (N + M - 1) // 2 - N * M)


if __name__ == "__main__":
    main()

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

#define ALL(x) x.begin(),x.end()

using namespace std;

typedef string::const_iterator State;



int num(State &begin){
    int ret=0;
    while (isdigit(*begin)){
        ret=ret*10+(*begin-'0');
        begin++;
    }
    return ret/2+1;
}

int lv=0;
int votemin(State &begin){
/* 
BNF:votemin=[num]|[{votemin}+]
*/
    
    lv++;
    begin++;
    if (isdigit(*begin)){ 
        lv--;
        return num(begin);
    }
    
    vector<int>v;
    while(*begin!=']' && *begin){
        int t=votemin(begin);
        begin++;
        v.push_back(t);
        if (!*begin){
            break;
        }

    }
    sort(ALL(v));
    int ret=0;
   
    rep(i,v.size()/2+1){
//        cerr<<lv<<":"<<v[i]<<endl;
        ret+=v[i];
    }
    lv--;
    return ret;
}


int main(){

    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        State begin=s.begin();
     //   cerr<<s<<endl;
        cout<<votemin(begin)<<endl;
    }

    return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a[3],b[3],c[3],d[3],e[3],f[3];
	for(int i=0;i<3;i++)
	{
		scanf("%d %d %d %d %d %d",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i]);
		if(f[i]-c[i]<0){e[i]-=1;f[i]+=60;}
		if(e[i]-b[i]<0){d[i]-=1;e[i]+=60;}
		printf("%d %d %d\n",d[i]-a[i],e[i]-b[i],f[i]-c[i]);
	}
	return 0;
}


Measured memory_bytes: 3204
var
	n,s,i:Longint;
	a,b:array[1..20]of Longint;
begin
	read(n);
	for i:=1 to n do read(a[i]);
	for i:=1 to n do read(b[i]);
	for i:=1 to n do begin
		if a[i]>b[i]then inc(s,a[i]-b[i]);
	end;
	writeln(s);
end.


Measured memory_bytes: 128
using System;

class Solution
{
  public static void Main(string[] args)
  {
    var nums = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int left = nums[0] + nums[1], right = nums[2] + nums[3];
    var ans = left == right ? "Balanced" : (left > right ? "Left" : "Right");
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    if (k % 2 == 0 || k % 5 == 0) {
      System.out.println("-1");
      return;
    }
    long count = 1;
    long rem = 0;
    long tmp = 7;
    while (true) {
      rem = (rem + tmp) % k;
      if (rem == 0) {
        System.out.println(count);
        return;
      }
      tmp = (tmp * 10) % k;
      count++;
    }
  }
}


Measured memory_bytes: 27136
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   string s,t;
   cin>>s;
   if(s=="Sunny")t="Cloudy";
    if(s=="Cloudy")t="Rainy";
    if(s=="Rainy")t="Sunny";
   cout<<t<<endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    k <- readLn
    -- 出力
    putStrLn $ show $ solve n k

solve :: Int -> Int -> Int
solve 0 k = 1
solve n k = if 2 ^ (n-1) > k then k + solve (n-1) k else 2 * solve (n-1) k


Measured memory_bytes: 508
var i,j,n,m,k,a:Longint;
f:array[1..30]of Longint;
begin
read(n,m);
for i:=1 to n do begin
	read(k);
	for j:=1 to k do begin
		read(a);
		inc(f[a]);
	end;
end;
k:=0;
for i:=1 to m do if f[i]=n then inc(k);
writeln(k);
end.

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

using namespace std;
int N;
string S;
int main(void) {

	cin >> N;
	cin >> S;

	while (1) {
		int q = 0;
		int sz = S.size();
		int sign = 0;
		int count = 0;
		for (q = 0; q < sz; q++) {
			if (S[q] == '(') { count++; }
			else { count--; }
			if (count < 0) { S = "(" + S; sign = 1; break; }
		}
		if (sign == 0) { break; }
    }


	int count = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '(') { count++; }
		else { count--; }
	}

	for (int j = 0; j < count; j++) {
		S += ")";
	}

	cout << S << endl;


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

#define MAX 100005
using namespace std;

int num[MAX];
int main( )
{
	int n;
	memset(num,0,sizeof(num));
	cin >> n;
	for(int j = 0; j < n; j++){
		int a;
		cin >> a;
		num[a - 1]++,num[a]++,num[a + 1]++; 
	}
	int ans = num[0];
	for(int j = 1; j < MAX; j++)
		ans = max(ans,num[j]);
	cout << ans << endl;
	return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vi v(n);
	ll sum = 0;
	REP(i, n) {
		cin >> v[i];
		sum += v[i];
	}
	ll c = (n + 1)*n / 2;
	if (sum % c != 0)cout << "NO" << endl;
	else {
		int k = sum / c;
		vi dif(n);

		int cnt = 0;
		REP(i, n)dif[i] = k + v[i] - v[(i + 1) % n];

		REP(i, n) {
			if (dif[i] > 0) {
				if (dif[i] % n == 0)cnt += dif[i] / n;
				else {
					cout << "NO" << endl;
					return 0;
				}
			}
			else if (dif[i] < 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
		if (cnt == k)cout << "YES" << endl;
		else cout << "NO" << endl;

	}
	return 0;
}


Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  long n, m;
  readf("%s %s\n", &n, &m);
  if (n <= m) {
    writeln("unsafe");
  } else {
    writeln("safe");
  }
}


Measured memory_bytes: 2788
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 998244353

func Solve() {
  var N int
  NextInt(&N)
  X := make([]int, N)
  for i, x := range NextLine() {
    if x == '1' { X[i]++ }
  }
  F := func(X []int) int {
    N := len(X)
    A, b := 0, 1
    for i := N - 1; 0 <= i; i-- {
      A = (A + b * X[i]) % p
      b = 2 * b % p
    }
    return A
  }
  LE := func(Y []int) bool {
    for i := 0; i < N; i++ {
      if X[i] != Y[i] { return Y[i] < X[i] }
    }
    return true
  }
  C := 2 * N * (F(X) + 1) % p
  D := make([][]int, 0)
  for k := 1; 3 * k <= N; k++ {
    if N % (2 * k) == k { D = append(D, []int{k, 0}) }
  }
  Y := make([]int, N)
  for i, d := range D {
    D[i][1] = F(X[:d[0]])
    for i := range Y { Y[i] = X[i % d[0]] ^ ((i / d[0]) % 2) }
    if LE(Y) { D[i][1]++ }
    for _, d2 := range D[:i] {
      if d[0] % d2[0] == 0 { D[i][1] = (D[i][1] - d2[1] + p) % p }
    }
    C = (C - (2 * (N - d[0]) * D[i][1] % p) + p) % p
  }
  Write(C)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 4480
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a>>b;
	if(a<=10)b+=100*(10-a);
	cout<<b<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    String s = cin.nextLine();
    if (s.length() < 4) {
      System.out.println("No");
    } else if ("YAKI".equals(s.substring(0, 4))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

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


int main() {
  int H,W;
  cin>>H>>W; 
  vector<vector<int>> c(10, vector<int>(10));
  rep(i,10) {
    rep(j,10) {
      cin >> c.at(i).at(j);
    }
  }
  vector<vector<int>> a(H, vector<int>(W));
  rep(i,H) {
    rep(j,W) {
      cin >> a.at(i).at(j);
    }
  }
  
  
  rep(k,10){
    rep(i,10) {
      rep(j,10) {
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  
  
  int ans=0;
  rep(i,H) {
      rep(j,W) {
        if(abs(a.at(i).at(j))!=1){
          ans+=c.at(a.at(i).at(j)).at(1);
        }
      }
  }
  
    cout << ans<< endl;
  
}

Measured memory_bytes: 384
""" AtCoder """
import itertools

n, m = (int(_) for _ in input().split())
sk = []
for _ in range(m):
    sk.append([int(__) for __ in input().split()][1:])
p = [int(_) for _ in input().split()]
ans = 0

for s in itertools.product([0,1], repeat=n):
    check = True
    for i, ski in enumerate(sk):
        skt = 0
        for skj in ski:
            skt += s[skj-1]
        if skt%2 != p[i]:
            check = False
            break

    if check == True:
        ans += 1

print(ans)


Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def unite(self, x, y):# UF.unite(a-1,b-1)
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):#今回は使っていない
        return -self.parents[self.find(x)]
 
    def same(self, x, y):#UF.same(a-1,b-1) True/False
        return self.find(x) == self.find(y)

N,M=map(int,input().split())

A=[0]*M;t=0;B=[0]*M

for i in range(M):
  a,b=map(int,input().split())
  A[i]=[a-1,b-1]
for t in range(M):
  UF=UnionFind(N)
  for i in range(M):
    if i!=t:
      UF.unite(A[i][0],A[i][1])
  if UF.same(A[t][0],A[t][1])==False:
    B[t]=1
print(sum(B))

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(k>=s.size()) cout << s << endl;
  else {
    s=s.substr(0,k)+"...";
    cout << s << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <sstream>
using namespace std;

#define namefile ""
#define inifile freopen(namefile".inp","r",stdin); freopen(namefile".out","w",stdout)
#define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef unsigned int uint;
typedef unsigned long ulong;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<string> VS;
typedef vector< VI > VVI;
typedef vector< VL > VVL;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;
typedef set<int> SETI;
typedef set<long> SETL;
typedef map<int,int> MII;
typedef map<long,long> MLL;

const long long MOD = 1e9+7;
const long long INFMAX = 1e9;
const long long INFMIN = -1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const double epsilon = 1e-9;
const double PI = acos(-1.00);
const int MAXN = 55;

int n,v[MAXN];

int main()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> v[i];

    sort(v+1,v+n+1);
    double res((double)(v[1]+v[2])/2);
    for (int i=3; i<=n; i++) res = (res+(double)v[i])/2;

    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

VI bfs(VVI &ab,ll s=0){
	deque<ll> que;// 次のNodeの値,今の通った数
	VI res(SZ(ab),-1);
	que.push_back(s);
	res[s]=s;
	while(!que.empty()){// 空になるまで
		ll now=que.front();que.pop_front();//先頭をとってくる
		for(ll id:ab[now]){
			if(res[id]!=-1) continue;
			res[id]=now;
			que.push_back(id);
		}
	}
	return res;
}

void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n>>m;
	VVI ab(n);
	VI ress(n);
	rep(i, m) {
		ll a,b;
		cin >> a>>b;
		a--;b--;
		ab[a].emplace_back(b);
		ab[b].emplace_back(a);
	}
	ress=bfs(ab,0);
	print("Yes");
	rep(i,n-1) print(1+ress[i+1]);

	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 13668
from fractions import math
n=int(input())
#first generate all primes uptil N
def chk_prime(n):
    sq=int(math.sqrt(n))
    for i in range(2,sq+1):
        if n%i==0:
            return False
    return True
primes=[]
for i in range(2,n+1):
    if chk_prime(i):
        primes.append(i)
#print(primes)
ans=1
mod=10**9+7
for i in primes:
    cnt=0
    for j in range(i,n+1,i):
        num=j
        while num%i==0:
            num//=i
            cnt+=1
    ans=(ans*(cnt+1))%mod
print(ans)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str,command,p;
	int q,a,b;
	cin >> str;
	cin >> q;
	if (q > 100)
		q = 100;
	for (int i = 0; i < q; i++){
		cin >> command >> a >> b;
		if (b > str.size() - 1)
			b = str.size() - 1;
		if (a > b)
			a = b;
		if (command == "print")
			cout << str.substr(a, b - a + 1) << endl;
		if (command == "reverse"){
			string tmp = str.substr(a, b - a + 1);
			string tmp2 = "";
			for (int j = 0; j < tmp.size(); j++){
				tmp2 += tmp.substr(tmp.size() - j - 1, 1);
			}
			str.replace(a, b - a + 1, tmp2);
		}
		if (command == "replace"){
			cin >> p;
			str.replace(a, b - a + 1, p);
		}
	}
}


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
int main(void){
    long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
     }else if(k <= a + b){
         cout << a << endl;
     }else{
         cout << a - (k - (a + b)) << endl;
     }
}


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

int main()
{
    int x,y,c=2,d=4,e=0,f;
    cin>>x>>y;
    f=x;
    while(f>=0)
    {
        if(c*f+d*e==y)
        {
            cout<<"Yes";
            return 0;
        }
        f-=1;
        e+=1;
    }
    cout<<"No";
    
		
}
	

Measured memory_bytes: 3636
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in a:
    if i<0:
        cnt+=1
s=0
for i in range(n):
    s+=abs(a[i])
if cnt%2==1:
    c=10**10
    for i in range(n):
        num=abs(a[i])
        if num<c:
            c=num
    s=s-(c*2)
print(s)

Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  map<char,int> m;
  rep(i,N) {
    m[S[i]]++;
  }
  int cur = 0;
  set<char> m2;
  int ma = 0;
  rep(i, N) {
    char c = S[i];
    m2.insert(c);
    m[c]--;
    if (m[c] == 0) {
      m.erase(c);
      m2.erase(c);
    }
    ma = max(ma, (int)m2.size());
  }
  cout << ma << endl;
}

Measured memory_bytes: 256
from collections import Counter
def main():
    N = int(input())
    T = {}
    for _ in range(N):
        S = input()
        T[S] = T.get(S, 0) + 1
    for i in ['AC', 'WA', 'TLE', 'RE']:
        print(i + ' x', T.get(i, 0))

main()
#print('Yes' if main() else 'No')
#print('YES' if main() else 'NO')


Measured memory_bytes: 69860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }

    ll sum = 0;
    ll ans1 = 0;
    ll ans2 = 0;
    rep(i, 0, n) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum <= 0) {
                ans1 += (1 - sum);
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                ans1 += (sum + 1);
                sum = -1;
            }
        }
    }

    sum = 0;
    rep(i, 0, n) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum >= 0) {
                ans2 += (sum + 1);
                sum = -1;
            }
        } else {
            if (sum <= 0) {
                ans2 += (1 - sum);
                sum = 1;
            }
        }
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}


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

using namespace std;

#define int			long long
#define endl		"\n"
#define ff			first
#define ss			second
#define mod			1000000007
#define inf			1e18
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;
	string s = "ACL";

	for (int i = 0; i < n; i++)
		cout << s;


	return 0;
}

Measured memory_bytes: 3532
(let ((a (read))
      (b (read))
      (c (read)))

  (defun get-f (x)
    (car (concatenate 'list (symbol-name x))))

  (defun get-b (y)
    (car (reverse (concatenate 'list (symbol-name y)))))


  (format t "~A~%"
          (if (and (char= (get-b a) (get-f b)) (char= (get-b b) (get-f c)))
            'yes
            'no)))


Measured memory_bytes: 23524
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S, class T> ostream& operator<<(ostream& o, const pair<S, T> &p) { return o << "(" << p.fs << "," << p.sc << ")"; }
template<class T> ostream& operator<<(ostream& o, const vector<T> &vc) { o << "sz = " << vc.size() << endl << "[";for (const T& v : vc) o << v << ",";o << "]";return o; }
typedef long long ll;


int main() {
    int N, A;
    cin >> N >> A;
    cout << ((N % 500 <= A) ? "Yes" : "No") << endl;
}

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

int main() {
    double x1, y1, x2, y2, dist;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));

    return 0;
}



Measured memory_bytes: 3216
// テストケースが存在しない疑惑
use std::io::{Read, Write};

fn my_swap(p: &mut [usize], ip: &mut [usize], ans: &mut Vec<usize>, a: usize) {
    let n = p.len() - 1;
    let (x, y) = (ip[0], ip[a]);
    assert!(a != 0 && a <= n);
    assert!(x <= n && y <= n);
    let v = if ans.len() % 2 == 0 {
        (n + 1 - x + y) % (n + 1)
    } else {
        (n + 1 - y + x) % (n + 1)
    };
    assert!(1 <= v && v <= n);
    ans.push(v);
    p.swap(x, y);
    ip.swap(0, a);
}

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let (p, ip) = {
        let mut p = vec![0; n + 1];
        let mut ip = vec![0; n + 1];
        for i in 1..(n + 1) {
            let k: usize = it.next().unwrap().parse().unwrap();
            assert!(1 <= k && k <= n && ip[k] == 0);
            p[i] = k;
            ip[k] = i;
        }
        (p, ip)
    };
    for i in 0..2 {
        let mut ans = vec![];
        let mut p = p.clone();
        let mut ip = ip.clone();
        for j in 1..(n + 1) {
            let k = (i + j) % (n + 1);
            if ip[j] == k {
                continue;
            }
            if ip[0] != k {
                let v = p[k];
                my_swap(&mut p, &mut ip, &mut ans, v);
            }
            my_swap(&mut p, &mut ip, &mut ans, j);
        }
        if ans.len() % 2 == 0 {
            writeln!(out, "1").unwrap();
            /*
            writeln!(out, "{}", ans.len()).expect("write fail");
            for v in ans.into_iter() {
                writeln!(out, "{}", v).unwrap();
            }
            */
            return;
        }
    }
    for i in 0..2 {
        let mut ans = vec![];
        let mut p = p.clone();
        let mut ip = ip.clone();
        for j in 1..(n + 1) {
            let k = (n + 1 + i - j) % (n + 1);
            if ip[j] == k {
                continue;
            }
            if ip[0] != k {
                let v = p[k];
                my_swap(&mut p, &mut ip, &mut ans, v);
            }
            my_swap(&mut p, &mut ip, &mut ans, j);
        }
        if ans.len() % 2 == 1 {
            writeln!(out, "1").unwrap();
            /*
            writeln!(out, "{}", ans.len()).unwrap();
            for v in ans.into_iter() {
                writeln!(out, "{}", v).unwrap();
            }
            */
            return;
        }
    }
    writeln!(out, "0").unwrap();
//    writeln!(out, "-1").unwrap();
}

fn main() {
    run();
}



Measured memory_bytes: 5040
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

a,b = map(int,input().split())

ma = [a+a-1,b+b-1,a+b]

print(max(ma))










Measured memory_bytes: 3316
#include <stdio.h>
#include <cmath>

int main(){
	int n, element, count = 0, limit;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%d", &element);
		limit = sqrt(element);
		for(int j = 2; j <= limit; j++){
			if(element % j == 0){
				count++;
				break;
			}
		}
	}
	printf("%d\n",n - count);
}



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

using namespace std;

int n, m;

vector<vector<pair<int, int>>> g;

vector<int> p;
vector<int> f;

bool dfs(int r, int x = 0) {
    
    f[r] = 1;
    p[r] = x;

    for (auto e : g[r]) {
        int to = e.first;
        int d = e.second;

        if (!f[to]) {
            if (!dfs(to, x + d)) {
                return false;
            }
        } else if (p[to] != p[r] + d) {
            return false;
        }
    }

    return true;
}


int main() {
    cin >> n >> m;

    g.resize(n);
    p.resize(n);
    f.resize(n);

    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;

        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    for (int i = 0; i < n; i++) {
        if (!f[i]) {
            if(!dfs(i)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


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

int main(void) {
    int N, A;
    int B[200000] = { 0 };
    int i;
    
    cin >> N;
    
    for (i = 1; i < N; i ++) {
        cin >> A;
        B[A - 1] ++;
    }
    
    for (i = 0; i < N; i ++) {
        cout << B[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4412