akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

struct Point{
    int idx;
    int x;
    int y;
    bool det= false;
};

bool x_sort(const Point& a, const Point& b){
    if(a.x!=b.x) return a.x<b.x;
    else return a.idx<b.idx;
}

bool y_sort(const Point& a, const Point& b){
    if(a.y!=b.y) return a.y<b.y;
    else return a.idx<b.idx;
}
bool idx_sort(const Point& a, const Point& b){
    return a.idx<b.idx;
}
int dist(const Point& a, const Point& b){
    return min(abs(a.x-b.x),abs(a.y-b.y));
}

vector<pair<int,int>> tonari[100010];


int main() {
    int N; cin>>N;
    vector<Point> p(N);
    int x,y;
    for (int i = 0; i < N; ++i) {
        cin>>x>>y;
        p[i]={i,x,y};

    }
    //cout<<p[1].x<<endl;

    sort(p.begin(),p.end(),x_sort);

    for (int i = 0; i < N - 1; ++i) {
        tonari[p[i].idx].push_back(make_pair(dist(p[i],p[i+1]),p[i+1].idx));
        tonari[p[i+1].idx].push_back(make_pair(dist(p[i],p[i+1]),p[i].idx));
    }

    sort(p.begin(),p.end(),y_sort);

    for (int i = 0; i < N - 1; ++i) {
        tonari[p[i].idx].push_back(make_pair(dist(p[i],p[i+1]),p[i+1].idx));
        tonari[p[i+1].idx].push_back(make_pair(dist(p[i],p[i+1]),p[i].idx));
    }

    sort(p.begin(),p.end(),idx_sort);
    ll ans=0ll;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> pq;
    pq.push(make_pair(0,0));
    while(!pq.empty()){
        int d=pq.top().first, to=pq.top().second;

        pq.pop();
        if(p[to].det) continue;
        p[to].det= true;
        ans+=(ll)d;
        //cout<<ans<<endl;
        for(auto itr:tonari[to]){
            pq.push(itr);
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 11896
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
long long a[N];
int main(){
	int time;
//	scanf("%d",&time);
//	while(time--){		
//	}
    int n,k;
    scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	int minx=0x3f3f3f3f;
	for(int i=1;i<=n-k+1;i++){
		if(a[i+k-1]-a[i]<minx){
			minx=a[i+k-1]-a[i];
		}
//		printf("%d   ",minx);
	}
//	printf("%d %d\n",maxn,minn);
	printf("%lld\n",minx);
//	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <iterator>
using namespace std;

int main()
{
    int n ,j,h;
    bool test1=true ;
    cin >> n;
    long long A[n];
    map <long long,int> test ;
    for (int i=0 ; i<n ; i++)
    {
        cin >> A[i] ;
        test[A[i]]+=1 ;
    }
     std::map<long long, int>::iterator it = test.begin();
     while(it != test.end())
    {
        if(it->second > 1 )
        {
            test1=false ;
        }
        it++;
    }
    if (test1==true)
    {
        cout<<"YES" ;
    }
    else {cout<< "NO" ;}
}

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

namespace AtTest.ABC_136
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int[] res = new int[s.Length];
            int odd = 0;
            int even = 0;
            for(int i = 0; i < s.Length; i++)
            {
                int tmp = odd;
                odd = even;
                even = tmp;
                if (s[i] == 'L')
                {
                    res[i - 1] += odd;
                    res[i] += even;
                    odd = 0;
                    even = 0;
                }
                else
                {
                    even++;
                }
            }
            for (int i = s.Length-1; i >=0; i--)
            {
                int tmp = odd;
                odd = even;
                even = tmp;
                if (s[i] == 'R')
                {
                    res[i + 1] += odd;
                    res[i] += even;
                    odd = 0;
                    even = 0;
                }
                else
                {
                    even++;
                }
            }

            for(int i = 0; i < s.Length; i++)
            {
                Write(res[i]);
                if (i < s.Length - 1) Write(" ");
            }
            WriteLine();
        }

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


Measured memory_bytes: 13920
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    cout << 800 * N - 200 * (N / 15) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		Arrays.sort(A);
		Arrays.sort(B);
		if(N % 2 == 1)
			System.out.println(B[N/2]-A[N/2]+1);
		else
			System.out.println(B[N/2]+B[N/2-1]-A[N/2]-A[N/2-1]+1);
	}

}

Measured memory_bytes: 61700
import numpy as np
n,k = map(int,input().split())
m = 10**9 + 7
gcds = np.zeros(k+1, int)
ans = 0

for i in range(k,0,-1):
  tmp = pow(k//i,n, m)
  for j in range(i*2,k+1,i):
    tmp -= gcds[j]
  ans = (ans + tmp*i)%m
  gcds[i] = tmp
print(ans)

Measured memory_bytes: 27312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod  1000000007
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld long double
#define fi first
#define se second
#define setbits __builtin_popcount
#define inf 1e18
int main()
{
    fastIO;
    string s,t;
    cin>>s>>t;
    cout<<t+s<<'\n';
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a < b && b < c)
        OP("Yes")
    else
        OP("No")

    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

int main()
{
    long long a, b, c, d;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%lld", max(max(a * c, a * d), max(b * c, b * d)));

    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define qq ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mid(l,r) l+(r-l)/2
typedef long long int ll;
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
using namespace std; 
int main() 
{
	qq;
	ll n,m,k;
  	cin>>n>>m;
  	ll  a[n][m];
  	for(ll i=0;i<n;i++)
  	{
  		for(ll j=0;j<m;j++)
  		{
  			cin>>a[i][j];
  		}
  	}
  	ll  count=0;
   long double s;
  	for(ll i=0;i<n-1;i++)
  	{
  		for(ll j=i+1;j<n;j++)
  		{
  			s=0;
  			for(k=0;k<m;k++)
  			{
  				s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
  			}
  			s=sqrt(s);
  			ll  s1=int(s);
  			if(s==s1)
  			count++;
  		}
  	}
  	cout<<count;
	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val c = IntArray(n+1)
	for(i in 2..n){
		primeFact(i).forEach {c[it]++}
	}
	
	var ans = 0
	ans += c.count{it>=74}
	ans += c.count{it>=24} * (c.count{it>=2}-1)
	ans += c.count{it>=14} * (c.count{it>=4}-1)
	ans += c.count{it>=4} * (c.count{it>=4}-1)/2 * (c.count{it>=2}-2)
	println(ans)
}

fun primeFact(a:Int):List<Int>{
	val primes= mutableListOf<Int>()
	var x=a
	val rtx=Math.sqrt(x.toDouble()).toInt()
	for(p in 2..a){
		if(x==1 || p>rtx && primes.isEmpty())break
		while(x%p==0){
			primes.add(p)
			x/=p
		}
	}
	if(primes.isEmpty()) primes.add(a)
	return primes
}

Measured memory_bytes: 33776
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a + W < b) {
      System.out.println(b - a - W);
    } else if (a > b + W) {
      System.out.println(a - b - W);
      } else if (a <= b && a + W >= b) {
        System.out.println(0);
        } else if (a >= b && b + W >= a) {
          System.out.println(0);
      }
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int A, B; cin>>A>>B;
  int d	= abs(A-B);
  if(d % 2 == 0) {
    cout << (A+B)/2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
    Sieve s(55555);
    int n;
    cin >> n;
    vector<int> ans;
    int now = 11;
    while (ans.size() < n) {
        if(s.isPrime(now)) ans.pb(now);
        now += 10;
    }
    rep(i,n) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
using namespace std;
bool find(vector<string>l,string s) {
	bool b = false;
	for (int i = 0; i < l.size(); i++){
		if (l[i] == s) {
			b = true;
			break;
		}
	}
	return b;
}
int main() {
	int n; cin >> n;
	vector<string>l;
	for (int i = 0; i < n; i++){
		string s; cin >> s;
		l.push_back(s);
	}
	cin >> n;
	bool b = false;//false->closed
	for (int i = 0; i < n; i++){
		string s; cin >> s;
		if (find(l,s) == true) {
			if (b){
				cout << "Closed by " << s << endl;
				b = false;
			}
			else{
				cout << "Opened by " << s << endl;
				b = true;
			}
		}
		else{
			cout << "Unknown " << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3216
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld; 

#define X first
#define Y second
#define MP make_pair

using namespace std;
    
const int N = 2e3 + 123;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

int n, m;
char c[N][N];
ll dp[N][N];

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			cin >> c[i][j];
		}
	}

	dp[1][1] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(c[i][j] == '#' || (i * j == 1))
				continue;
			ll need = 0;
			if(c[i - 1][j] != '#')
				need += dp[i - 1][j];
			if(c[i][j - 1] != '#')
				need += dp[i][j - 1];
			dp[i][j] = need % mod;
		}
	}
	        /*
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	          */
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
bool ok = 0;
string s;
int main(){
    ll l,r,ans;
    cin >> l >> r;
    if(r - l  >=2019) cout<<0<<endl;
    else{
        ans = 2019;
        for(ll i = l;i < r; i++){
            for(ll j = i+1;j <=r ; j++){
                ans = min(ans,(i*j)%2019);
            }            
        }
        cout<<ans<<endl;
    }
    //
}


Measured memory_bytes: 3644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	ans := 0
	for _, r := range s {
		if string(r) == "+" {
			ans++
		} else {
			ans--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  int n;
  string s,t;
  cin >> n>>s>>t;
  
  rep(i,n) {
    cout << s[i] << t[i];
  }
  
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        vll a(n+11);
        vll pre(n+11);
        vll suff(n+11);
        for(i=1;i<=n;i++){
                cin>>a[i];
                pre[i]=gcd(pre[i-1],a[i]);
        }
        for(i=n;i>=1;i--){
                suff[i]=gcd(suff[i+1],a[i]);
        }
        ll ans=1;
        for(i=1;i<=n;i++){
                ans=max(ans,gcd(pre[i-1],suff[i+1]));
        }
        cout<<ans<<endl;
        
        
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 5536
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cs: chars
    }
    let len = cs.len() / 2;
    let cs2 = cs.clone().into_iter().rev().collect::<Vec<char>>();
    let mut cnt = 0;
    for i in 0..len {
        if cs[i] != cs2[i] {
            cnt += 1;
        }
    }

    println!("{}", cnt);
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != (n // i):
                divisors.append(n // i)
    return divisors

print(sum(1 for j in range(1, n + 1) if len(make_divisors(j)) == 8 and j % 2 == 1))


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

//???????????°?????????????????°
int cnt=0;


void insertionSort(int* A,int n,int g){

	for(int i=g; i<=n-1; i++){
		int v = A[i];
		int j=i-g;
		while(j >= 0 && A[j] > v){
			A[j+g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j+g] = v;
	}
}

void shellSort(int* A, int n){
	cnt = 0;
	
	vector<int> G;

	int c= 1;
	do{	
		G.push_back(c);
	}while((c = c*3+1) <= n);

	int m = G.size();

	cout << m << endl;
	for(int i=m-1; i>= 0; i--){

		// ??°???G???????????????
		cout << G[i];
		
		cout << " ";	

		insertionSort(A, n, G[i]);
	}

	cout << endl;
}

int main(void){
	int N;
	cin >> N;
	int A[N];	//????????????????????°???
	for(int i=0; i<N; i++)
		cin >> A[i];
	
	
	shellSort(A,N);

	cout << cnt << endl;
	
	for(int i=0; i<N; i++){
		//??´???????????°????????????
		cout << A[i] << endl;

	}

	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MAX_PRIME 1000000
bool isprime[MAX_PRIME+1];
vector<int> primes;
void init_prime(){
  fill(isprime, isprime+MAX_PRIME+1, true);
  isprime[0] = isprime[1] = false;
  for(int i = 2; i <= MAX_PRIME; i++) {
    if (isprime[i]) {
      primes.push_back(i);
      for(int j = i*2; j <= MAX_PRIME; j += i)
      isprime[j] = false;
    }
  }
}

int main(){
  init_prime();

  int X;
  cin >> X;
  rep(i,primes.size()){
    if(X <= primes[i]){
      cout << primes[i] << endl;
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 4744
open Num;;

Scanf.scanf "%d" (fun t ->
    let module M = Map.Make (struct type t = int let compare = compare end) in
    for i = 1 to t do
        Scanf.scanf " %d %d %d %d %d" (fun n a b c d ->
            let rec calc =
                let map = ref (M.add 0 (Int 0) (M.singleton 1 (Int d))) in
                fun k ->
                if M.mem k !map then M.find k !map else (
                    let ans = Int k */ Int d in
                    let ans = List.fold_left (fun acc i ->
                        if (k + i) mod 2 <> 0 then acc else
                            min_num acc (calc ((k + i) / 2) +/ Int a +/ Int d */ Int (abs i))
                            ) ans [ -1; 0; 1 ]
                    in
                    let ans = List.fold_left (fun acc i ->
                        if (k + i) mod 3 <> 0 then acc else
                            min_num acc (calc ((k + i) / 3) +/ Int b +/ Int d */ Int (abs i))
                            ) ans [ -1; 0; 1 ]
                    in
                    let ans = List.fold_left (fun acc i ->
                        if (k + i) mod 5 <> 0 then acc else
                            min_num acc (calc ((k + i) / 5) +/ Int c +/ Int d */ Int ( abs i))
                            ) ans [ -2; -1; 0; 1; 2 ]
                    in
                    map := M.add k ans !map;
                    ans
                  )
            in
            Printf.printf "%s\n" @@ string_of_num (calc n)
        )
    done
)

Measured memory_bytes: 8280
import sys
from bisect import bisect_right, bisect_left

def to_cumsum(arr, pad=True):
    """
    1次元配列を累積和の1次元配列に変換する
    pad: 先頭に0の項を作る場合はTrue
    """
    cumsum = 0
    padding = 1 if pad else 0
    new = [0] * (len(arr) + padding)
    for i, e in enumerate(arr):
        cumsum += e
        new[i + padding] = cumsum
    return new

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


X, Y, A, B, C = MI()
P = LMI()
Q = LMI()
R = LMI()

P.sort(reverse=True)
Q.sort(reverse=True)

R.extend(P[:X])
R.extend(Q[:Y])

R.sort(reverse=True)
print(sum(R[:X + Y]))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 1510;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int a[maxN][maxN];
int b[maxN];
int c;
int n,m; 

int main()
{
	scanf("%d%d%d",&n,&m,&c);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		int ans = 0;
		for(int j=1;j<=m;j++)
		{
			ans += a[i][j] * b[j];
		}
		if(ans + c > 0)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ar[n] = {};
    int m, t;
    for (int ctr1 = 0; ctr1 < k; ++ctr1) {
        cin >> m;
        for (int ctr2 = 0; ctr2 < m; ++ctr2)
            cin >> t, ++ar[t - 1];
    }
    int rez = 0;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        rez += ar[ctr1] == 0;
    cout << rez << '\n';
    return 0;
}


Measured memory_bytes: 3704
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

VV g;
V dp;
int dfs(int x) {
	if (dp[x]) return dp[x];
	V v;
	for (auto& t : g[x]) {
		v.push_back(dfs(t));
	}
	sort(all(v));
	reverse(all(v));
	int tmp = 0;
	rep(i, (int)v.size()) tmp = max(tmp, v[i] + i + 1);
	return dp[x] = tmp;
}

signed main() {
	int N; cin >> N;
	g.resize(N);
	dp.resize(N);
	rep(i, 1, N) {
		int a; cin >> a;
		a--;
		g[a].push_back(i);
	}
	cout << dfs(0) << endl;
	system("pause");
}

Measured memory_bytes: 16120
from heapq import heappush, heappop

N, K = map(int, input().split())
A = list(map(int, input().split()))

h_max = []
h_min = []
for i in range(K):
  heappush(h_min,  A[i])
  heappush(h_max, -A[i])

check = [0] * (N + 1)
tmp = [0] * N
tmp[0] = 1
for i in range(N - K):
  
  a_min =  heappop(h_min)
  a_max = -heappop(h_max)
  while check[a_min]:
    a_min =  heappop(h_min)
  while check[a_max]:
    a_max = -heappop(h_max)
  if A[i] == a_min and A[i + K] > a_max:
    tmp[i + 1] -= 1
  check[A[i]] = 1
  heappush(h_min,  a_min)
  heappush(h_max, -a_max)  
  heappush(h_min,  A[i + K])
  heappush(h_max, -A[i + K])  
  tmp[i + 1] += 1

B = [0]
for i in range(1, N):
  if A[i] > A[i - 1]:
    B.append(1)
  else:
    B.append(0)

sum_B = sum(B[1: K])
flag = 0
for i in range(N - K + 1):
  if sum_B == K - 1:
    if tmp[i]:
      flag = 1
      tmp[i] = 0
  if i == N - K:
    break
  sum_B = sum_B - B[i + 1] + B[i + K]

print(sum(tmp) + flag)

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

using namespace std;

int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k % 2 == 0) {
        cout << a - b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	int ans = 0, z = 0;
	repp(i,0,N){
		int a; cin >> a;
		if(z == a){
			++ans;
			z = 0;
		} else {
			z = a;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(n: usize, mut a: [usize; n]);
    a.sort_by(|x, y| y.cmp(x));
    let mut ans = 0;
    for i in 1..n {
        ans += a[i / 2];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6236
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
al = 0
for v in ctr.values():
    al += v*(v-1)//2

ans = []
for a in A:
    ans.append(al - ctr[a] + 1)
print(*ans, sep='\n')

Measured memory_bytes: 30716
#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
const int N=81;
int n,a[N];
ll f[N];
int main(){
//	freopen("D.in","r",stdin);
//	freopen("D.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	f[0]=1000;
	for(int i=1;i<=n;++i){
		f[i]=f[i-1];
		for(int j=1;j<=i-1;++j)if(a[j]<a[i])
			f[i]=max(f[i],f[j-1]+f[j-1]/a[j]*(a[i]-a[j]));
	}
	cout<<f[n]<<endl;
	return 0;
}


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

int main() {
	int n;
	string ans = "No";
	std::cin >> n;
	
	for (int i = 0; i < 10; i++) {
	    for (int j = 0; j < 10; j++) {
	        if(i*j==n) ans = "Yes";
	    }
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a'){
    cout << "vowel" << endl; 
    return 0;
  }
  if(c == 'e'){
    cout << "vowel" << endl; 
    return 0;
  }
  if(c == 'i'){
    cout << "vowel" << endl; 
    return 0;
  }
  if(c == 'o'){
    cout << "vowel" << endl; 
    return 0;
  }
  if(c == 'u'){
    cout << "vowel" << endl; 
    return 0;
  }
  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
void drawRectangle( int H, int W)
{
    int i,j;
     
    for( i=0; i<H; i++) {
        for( j=0; j<W; j++) {
            printf( "#");
        }
        printf( "\n");
    }
    printf( "\n");
    return;
}
 
int main( void ) 
{
    int H,W;
 
    for( ; ; ) {
        scanf( "%d%d", &H, &W ); 
        if( 0==H && 0==W ) { break; }
 
        drawRectangle( H, W );
    }
 
    return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli N,A,B;
  cin >> N >> A >> B;
  lli ans;
  ans=N/(A+B)*A;
  if(N%(A+B)<A)
    cout << ans+N%(A+B) << endl;
  else
    cout << ans+A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<int> bars(n); for (auto& b : bars) std::cin >> b;
	std::sort(bars.begin(), bars.end());
	int count = 0;
	for (auto i = 0; i < n; ++i) {
		for (auto j = i + 1; j < n; ++j) {
			for (auto k = j + 1; k < n; ++k) {
				if (bars[i] + bars[j] > bars[k]) ++count;
			}
		}
	}
	std::cout << count << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int64_t mod = 1e9 + 7;

#define M 1046527
#define NIL (-1)
#define L 14

vector<string> H(M);

int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

int getKey(string S) {
	int sum = 0, p = 1;
	for (int i = 0; i < S.size(); i++) {
		sum += p * getChar(S.at(i));
		p *= 5;
	}

	return sum;
}

int h1(int key) {
	return key % M;
}

int h2(int key) {
	return 1 + (key % (M - 1));
}

int find(string S) {
	int key, h;
	key = getKey(S);
	for (int i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (H.at(h) == S) return 1;
		else if (H.at(h).size() == 0) return 0;
	}
}

int insert(string S) {
	int key, h;
	key = getKey(S);
	for (int i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (H.at(h) == S) return 1;
		else if (H.at(h).size() == 0) {
			H.at(h) = S;
			return 0;
		}
	}

	return 0;
}

int main() {
	int n, h;
	string S, com;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> com >> S;
		if (com.at(0) == 'i') {
			insert(S);
		}
		else {
			if (find(S)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
}


Measured memory_bytes: 27364
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof (c.begin()) i=c.begin(); i!=c.end(); i++)
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;

const int mod=100000007;
int dp[100001][6],dp2[100001][4];
int sum[100001],sum2[100001];
string in;

int main(){
  dp[0][0]=dp2[0][0]=1;
  
  rep(i,100000)rep(j,6){
    if(j<5)(dp[i+1][j+1]+=dp[i][j])%=mod;
    (dp[i+1][1]+=dp[i][j])%=mod;
  }
  rep(i,100000)rep(j,4){
    if(j<3)(dp2[i+1][j+1]+=dp2[i][j])%=mod;
    (dp2[i+1][1]+=dp2[i][j])%=mod;
  }
  rep(i,100001){
    rep(j,6)(sum[i]+=dp[i][j])%=mod;
    rep(j,4)(sum2[i]+=dp2[i][j])%=mod;
  }
  rep(i,100001){
    if(i>5)(sum[i]+=sum[i-6])%=mod;
    if(i>3)(sum2[i]+=sum2[i-4])%=mod;
  }
  
  while(getline(cin,in),in!="#"){
    int cnt=0;
    vi v,type;
    rep(i,in.size()){
      if(i&&in[i]!=in[i-1]){
        v.pb(cnt); cnt=1;
        type.pb(in[i-1]=='0'||in[i-1]=='8');
      }
      else cnt++;
    }
    type.pb(in[in.size()-1]=='0'||in[in.size()-1]=='8');
    v.pb(cnt);

    ll ans=1;
    rep(i,v.size()){
        if(!type[i])(ans*=sum[v[i]-1])%=mod;
        else (ans*=sum2[v[i]-1])%=mod;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    string s, t;
    cin >> s >> t;
    ll n = s.length();
    ll m = t.length();
    vector<string> ans;

    if (n < m)
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (ll i = 0; i <= n - m; i++)
    {
        bool ok = true;
        string tmp = s;
        for (ll j = 0; j < m; j++)
        {
            if (s[i + j] != '?' && s[i + j] != t[j])
                ok = false;
            tmp[i + j] = t[j];
        }
        if (ok)
            ans.push_back(tmp);
    }

    if (ans.size() == 0)
    {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        sort(ans.begin(), ans.end());
        rep(i, n)
        {
            if (ans[0][i] == '?')
                ans[0][i] = 'a';
        }
        cout << ans[0] << endl;
    }
}

Measured memory_bytes: 3636
n, m = [ int(v) for v in input().split() ]
status = [ "WA" for i in range(n) ]
penarty = [0 for i in range(n)]
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if status[p] == "WA":
        if s == "WA":
            penarty[p] += 1
        elif s == "AC":
            status[p] = "AC"
total_penarty = sum([ penarty[i] for i in range(n) if status[i] == "AC" ])
print(status.count("AC"), total_penarty)

Measured memory_bytes: 52016
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll X, A, B, C;
	cin >> A >> B >> C >> X;
	
	ll cnt = 0;

	for (ll i = 0; i <= A; i++) {
		for (ll j = 0; j <= B; j++) {
			for (ll k = 0; k <= C; k++) {
				if (X == 500 * i + 100 * j + 50 * k) {
					cnt++;
				}
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double dist(double x1, double y1, double x2, double y2)
{
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
	int N, j;
	double xa, ya, ra, xb, yb, rb;
	double d;
	scanf("%d", &N);
	while (N--) {
		scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb);
		d = dist(xa, ya, xb, yb);
		if (d+rb < ra)
			j = 2;
		else if (d+ra < rb)
			j = -2;
		else if (ra+rb < d)
			j = 0;
		else
			j = 1;
		printf("%d\n", j);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#define N 100
using namespace std;

int main() {
  int n, p[N + 1], m[N + 1][N + 1], i, j, k, l;
  cin >> n;
  for(i = 1; i <= n; i++) {
    cin>>p[i - 1]>>p[i];
  }

  for(i = 1; i <= n; i++) m[i][i] = 0;
  for(l = 2; l <= n; l++) {
    for(i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      m[i][j] = (1 << 21);
      for(k = i; k <= j - 1; k++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout<<m[1][n]<<endl;

  return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <vector>
#include <stack>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <list>
using namespace std;

int main()
{
  int a,b,c; cin >> a >> b >> c;
  
  if(c <= b && a <= c) cout << "Yes" << endl;
  else if(c <= a && b <= c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5+5;
const int MOD=1e9+7;

int main(){
	string S;
	cin>>S;
	int l=S.size();
	lli A[2],AB[3],ABC[4];
	//?の個数をカウント
  	int Q=0;
	
	//S[0]
	if(S[0]=='A'){
		ABC[0]=0;ABC[1]=0;ABC[2]=0;ABC[3]=0;
		AB[0]=0;AB[1]=0;AB[2]=0;
		A[0]=1;A[1]=0;
	}
	else if(S[0]=='B'){
		ABC[0]=0;ABC[1]=0;ABC[2]=0;ABC[3]=0;
		AB[0]=0;AB[1]=0;AB[2]=0;
		A[0]=0;A[1]=0;
	}
	else if(S[0]=='C'){
		ABC[0]=0;ABC[1]=0;ABC[2]=0;ABC[3]=0;
		AB[0]=0;AB[1]=0;AB[2]=0;
		A[0]=0;A[1]=0;
	}
	else{
      	Q++;
		ABC[0]=0;ABC[1]=0;ABC[2]=0;ABC[3]=0;
		AB[0]=0;AB[1]=0;AB[2]=0;
		A[0]=0;A[1]=1;
	}
	
	//S[1]
	if(S[1]=='A'){
		A[0]=A[0]+1;
	}
	else if(S[1]=='B'){
		AB[1]=AB[1]+A[1];AB[0]=AB[0]+A[0];
	}
	else if(S[1]=='C'){
		A[0]=A[0];
	}
	else{;
        Q++;
		AB[2]=AB[2]+A[1];AB[1]=AB[1]+A[0];
		A[0]=A[0];A[1]+=1;
	}
	
	//S[i]
	for(int i=2;i<l;i++){
		if(S[i]=='A'){
			A[0]=A[0]+1;
		}
		else if(S[i]=='B'){
			AB[0]=(AB[0]+A[0])%MOD;AB[1]=(AB[1]+A[1])%MOD;
		}
		else if(S[i]=='C'){
			ABC[0]=(ABC[0]+AB[0])%MOD;ABC[1]=(ABC[1]+AB[1])%MOD;ABC[2]=(ABC[2]+AB[2])%MOD;
		}
		else{
          	Q++;
			ABC[3]=(ABC[3]+AB[2])%MOD;ABC[2]=(ABC[2]+AB[1])%MOD;ABC[1]=(ABC[1]+AB[0])%MOD;
			AB[2]=(AB[2]+A[1])%MOD;AB[1]=(AB[1]+A[0])%MOD;
			A[1]+=1;
		}
	}
	
	lli ans;
	//Q==0なら答えはABC[0]
	if(Q==0)ans=ABC[0];
	
	//Q==1なら答えはABC[0]*3+ABC[1]
	else if(Q==1)ans=(ABC[0]*3+ABC[1])%MOD;
	
	//Q==2なら答えはABC[0]*9+ABC[1]*3+ABC[2]
	else if(Q==2)ans=(ABC[0]*9+ABC[1]*3+ABC[2])%MOD;

	//Q>2なら答えはABC[0]*3^Q+ABC[1]*3^(Q-1)+ABC[2]*3^(Q-2)+ABC[3]*3^(Q-3)
  	else{
  		ans=(ABC[0]*27+ABC[1]*9+ABC[2]*3+ABC[3])%MOD;
  		rep(i,Q-3)ans=(ans*3)%MOD;
  	}
  	cout<<ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    
    bool ok = false;
    rep(i, n+1){
        rep(j, m+1){
            int t = i*m + j*n - 2*j*i;
            if(t == k) ok = true;
        }
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

bool answer[100001];
int penalty[100001];
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, m) {
		ll p; string s; cin >> p >> s;
		if (s == "AC") {
			answer[p] = true;
		}
		else {
			if (!answer[p]) {
				penalty[p]++;
			}
		}
	}

	ll A = 0;
	ll P = 0;
	rep(i, 1, n+1) {
		if (answer[i]) {
			A++;
			P += penalty[i];
		}
	}

	cout << A << " " << P << endl;
	return 0;
}



Measured memory_bytes: 768
local s = io.read()
local n = #s
local cnt = 0
local t = {}
for i = 1, n do
  local sstr = s:sub(i, i)
  if sstr == "x" then
    cnt = cnt + 1
  else
    local tmp = {}
    tmp.c = cnt
    tmp.s = sstr
    table.insert(t, tmp)
    cnt = 0
  end
end
local ret = 0
local mab = math.abs
local nt = #t
local isok = true

local half = nt // 2
for i = 1, half do
  if t[i].s ~= t[nt + 1 - i].s then
    isok = false
    break
  else
    if i == 1 then
      ret = ret + mab(t[i].c - cnt)
    else
      ret = ret + mab(t[i].c - t[nt + 2 - i].c)
    end
  end
end
if nt % 2 == 1 then
  if nt == 1 then
    ret = ret + mab(t[1].c - cnt)
  else
    ret = ret + mab(t[half + 1].c - t[half + 2].c)
  end
end
print(isok and ret or -1)


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


int main() {

    ll n;
    cin >> n;
    if (n % 2 == 0) cout << n << endl;
    else cout << 2*n << endl;
    return 0;
}

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

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);

    int k;
    long long ans = 0;
    cin >> k;
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= k; ++j){
            for(int l = 1; l<= k; ++l){
                ans += __gcd(i, __gcd(j, l));
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3648
import numpy as np

words = lambda t : list(map(t, input().split()))
n,d = words(int)

a = []
for i in range(n):
    k = words(int)
    a.append(k)

def dist(x,y):
    ttl = 0
    for x1,y1 in zip(x,y):
        ttl += (abs(x1 - y1))**2
    return np.sqrt(ttl)

ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ds = dist(a[i], a[j])
        #print(i, j, a[i], a[j], ds)
        if ds == round(ds):
            ans += 1

print(ans)


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> dist(100010),edges[100010];
int ans = 0,d = 0;

int dfs(int i,int k) {
    int d = 0;
    for (int& j : edges[i]) d = max(d,dfs(j,k)+1);
    if (d == k-1 && dist[i] != 1 && i) {
        d = -1;
        ans++;
    }
    return d;
}

int main() {
    int n,k;
    cin >> n >> k;
    int a;
    cin >> a;
    if (a != 1) ans++;
    for (int i = 1;i < n;++i) {
        cin >> a;
        edges[a-1].push_back(i);
        if (a == 1) dist[i] = 1;
    }
    dfs(0,k);
    cout << ans << endl;
}

Measured memory_bytes: 12416
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/25 11:52:23 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll	n;
	cin >> n;

	vector<ll>	V(n);
	ll	total;
	total = 0;
	rep(i, n)
	{
		ll	x;
		cin >> x;

		total += x;
		V.at(i) = total;
	}
	ll	minv;
	minv = INT_MAX;
	rep(i, n - 1)
		minv = min(minv, abs(2 * V.at(i) - total));
	cout << minv << endl;
}
// END

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


Measured memory_bytes: 1792