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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    string s, t;
    cin >> s >> t;

    int N = s.length() - t.length() + 1;

    int mincount = 2000;
    for (int i = 0; i < N; i++)
    {
        int counter = t.length();
        for (int j = 0; j < t.length(); j++)
        {
            if (s[i + j] == t[j])
                counter--;
        }
        mincount = min(mincount, counter);
    }

    int ans = mincount;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

vector<bool> visit;
vector< vector<int> > gra;
int A,B;
void dfs(int v){
	visit[v] = true;
	int size = gra[v].size();
	int a,b;

	for(int i=0;i<size;++i){
		int to = gra[v][i];
		a = v;
		b = to;
		if( a > b )swap(a,b);
		if( A==a && B==b ) continue;
		if( visit[to] ) continue;//訪問済み
		dfs(to);
	}
}
void solve(){
	int N,M;
	cin >> N >> M;
	
	gra=vector< vector<int> >(N);

	vector< pair<int,int> > edge(M);
	for(int i=0;i<M;++i){
		int u,v;
		cin >> u >> v;
		--u;--v;
		if( u > v ) swap(u,v);
		edge[i].first = u;
		edge[i].second = v;

		gra[u].push_back( v );
		gra[v].push_back( u );
	}
	
	int ans = 0;
	for(int i=0;i<M;++i){
		visit.assign(N,false);
		A = edge[i].first;
		B = edge[i].second;
		dfs(0);
		int res = 0;
		for(int j=0;j<N;++j){
			if( visit[j] ){
				++res;
			}
		}
		if( res != N ){
			++ans;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
from collections import Counter, defaultdict

n = int(input())
a = list(map(int, input().split()))
dic = Counter(a)
memo1 = set()
memo2 = set()

MAX = 10 ** 6 + 1
for i in a:
  if i in memo1:
    continue
  if i in dic:
    if dic[i] > 1:
      memo2.add(i)
  for j in range(i*2, MAX, i):
    if j in dic:
      memo2.add(j)
  memo1.add(i)
ans = len(memo1) - len(memo2)
print(ans)

Measured memory_bytes: 154832
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N;cin>>N;
  set<int> s;
  REP(i,N){
    int d;cin>>d;
    s.insert(d);
  }
  int ans=s.size();
  P(ans);
  return 0;
}


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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int x;
   cin >> x;
   cout << 360 / __gcd(x , 360);
   return 0;
}


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

int main(){
    int cards[4][14];
    int n, kg;
    char ln;
    for(int i = 0;i < 4;++i){
       for( int j = 1;j < 14;++j){
         cards[i][j] = 0;
        }      
      }
    cin >> n;
    for( int o = 0; o < n;o++){
       cin >> ln >> kg;
       if( ln == 'S') cards[0][kg] = 1;
       if( ln == 'H') cards[1][kg] = 1;
       if( ln == 'C') cards[2][kg] = 1;
       if( ln == 'D') cards[3][kg] = 1;
      }
    for(int x = 0;x < 4;x++){
       for(int y = 1;y < 14;y++){
         if(cards[x][y] == 1) continue;
         if(x == 0) cout << 'S' << " " << y << endl;
         if(x == 1) cout << 'H' << " " << y << endl;
         if(x == 2) cout << 'C' << " " << y << endl;
         if(x == 3) cout << 'D' << " " << y << endl;
         }
       }
   return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define N 1001000
#define inf INT_MAX
inline int read()
{
    int s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
int n;
char a[N],b[N];
int pos[N],Ans,cnt,ans[N];
bool Chtholly=true;
int main()
{
    //freopen("game.in","r",stdin);
    //freopen("game.out","w",stdout);
    n=read();
    scanf("%s%s",a+1,b+1);
    int len=1;
    //while(a[len]==b[len])
    //for(int i=1;i<=n+10;i++) cout<<a[i]<<endl;
    while(a[len]==b[len]&&len<=n) len++;
    if(len==n+1) return puts("0"),0;
    int front=n+1,rear=n;
    int k=n+1;
    while(n)
    {
        int j=n;
        while(b[j-1]==b[n]&&j>=1) j--;
        k=min(k,j);
        while(a[k]!=b[n]&&k>=1) k--;
        if(!k) {Chtholly=false;break;}
        while(front<=rear&&pos[rear]-cnt>n) rear--;
        cnt++;
        front--;
        pos[front]=k+cnt;
        ans[front]=cnt;
        Ans=max(Ans,cnt-ans[rear]+1);
        n=j-1;
    }
    if(!Chtholly) {puts("-1");return 0;}
    printf("%d\n",Ans);
    return 0;
}


Measured memory_bytes: 9984
from fractions import gcd
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    L=lcm(L,i)
ans=0
for i in a:
    ans+=L//i
print(ans%(10**9+7))

Measured memory_bytes: 6112
object Main extends App {

  def caesar(ch: Char): Char = ch match {
    case 'a' => 'b'
    case 'b' => 'c'
    case 'c' => 'd'
    case 'd' => 'e'
    case 'e' => 'f'
    case 'f' => 'g'
    case 'g' => 'h'
    case 'h' => 'i'
    case 'i' => 'j'
    case 'j' => 'k'
    case 'k' => 'l'
    case 'l' => 'm'
    case 'm' => 'n'
    case 'n' => 'o'
    case 'o' => 'p'
    case 'p' => 'q'
    case 'q' => 'r'
    case 'r' => 's'
    case 's' => 't'
    case 't' => 'u'
    case 'u' => 'v'
    case 'v' => 'w'
    case 'w' => 'x'
    case 'x' => 'y'
    case 'y' => 'z'
    case 'z' => 'a'
    case x => x
  }

  val sc = new java.util.Scanner(System.in)
  while(sc.hasNext()) {
    val input = sc.nextLine()
    var arr = input.toCharArray
    for (i <- 0 until 26) {
      for (j <- 0 until arr.length) {
        if (arr(j) != ' ' && arr(j) != '.') {
          arr(j) = caesar(arr(j))
        }
      }
      val str = new String(arr)
      if (str.contains("the") || str.contains("this") || str.contains("that")) println(str)
    }
  }

}

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

vector<int> knuth_morris_pratt(const string &s){
    int n=s.size();
    //vector<int> kmp(n+1,-1),mp(n+1,-1);
    vector<int>kmp(n+1,-1);
    for(int i=0,j=-1;i<n;i++){
        while(~j&&s[i]!=s[j]) j=kmp[j];
        //kmp[i+1]=mp[i+1]=++j;
        j++;
        if(i+1<n&&s[i+1]==s[j]) kmp[i+1]=kmp[j];
        else kmp[i+1]=j;
    }
    //return mp;
    return kmp;
}
// smallest d s.t. s[x] == s[x + d] for all x
vector<int> minimum_period(const string &s){
    auto mp=knuth_morris_pratt(s);
    for(int i=1;i<(int)mp.size();i++) mp[i]=i-mp[i];
    return mp;
}
// positions for t that match s
vector<int> pattern_match(string s,string t){
    int n=s.size(),m=t.size();
    vector<int> kmp=knuth_morris_pratt(s);

    vector<int> res;
    int i=0,j=0;
    while(i+j<m){
        if(s[j]==t[i+j]){
            if(++j!=n) continue;
            res.emplace_back(i);
        }
        i+=j-kmp[j];
        j=max(kmp[j],0);
    }
    return res;
}

int main() {
    string s, t;
    cin >> s >> t;

    auto idxs = pattern_match(t, s);
    for (auto idx: idxs) cout << idx << endl;
}



Measured memory_bytes: 9412
#include <iostream>
using namespace std;
int main () {
	int n;
	while (cin >> n, n) {
		for (; n; n--) {
			int q[2][4], mat[4][4];
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 4; j++) {
					cin >> q[i][j];
				}
			}
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					mat[i][j] = q[0][i] * q[1][j];
				}
			}
			cout << (mat[0][0] - mat[1][1] - mat[2][2] - mat[3][3]) << ' '
				 << (mat[0][1] + mat[1][0] + mat[2][3] - mat[3][2]) << ' '
				 << (mat[0][2] - mat[1][3] + mat[2][0] + mat[3][1]) << ' '
				 << (mat[0][3] + mat[1][2] - mat[2][1] + mat[3][0]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M;
  cin >> N >> M;

  vector<int> vec(N, INF);
  int s, c;
  int flag = 1;
  REP(i, M){
    cin >> s >> c;
    s--;
    if(vec[s] == INF) vec[s] = c;
    else if(vec[s] != c){
      flag = 0;
    }
  }

  REP(i, N){
    if(vec[i] == INF){
      if(i == 0 && N != 1) vec[i] = 1;
      else vec[i] = 0;
    }
  }
  if(vec[0] == 0 && N != 1) flag = 0;
  if(flag){
    REP(i, N) cout << vec[i];
    cout << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	vector <int>v;
	for (int i = 0; i < s.length(); i++) {
		int c = count(s.begin(), s.end(), s[i]);
		v.push_back(c);
	}
	int x = 0;
	for (int j = 0; j < v.size(); j++) {
		if (v[j] % 2 != 0) {
			x++;
		}
	}
	if (x == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 3636
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

n,m,x = map(int,input().split())
a = [int(x) for x in input().split()]
for i in range(m):
    if a[i] > x:
        break
if i > m-i:
    i = m -i
print(i)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;



int main() {
	int H, W, N;
	cin >> H >> W >> N;
	cout << N / (max(H, W)) + bool(N % max(H, W)) << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

# semi_A = []
tmp = A[0] // 2
# for a in A:
#     semi_A.append(a // 2)


for i in range(1, N):
    # tmp = (A[i] // 2)
    # a[0]とa[1]で2で割り切れる数が異なればダメ

    if abs(A[0] // 2 - A[i] // 2) % gcd(A[0], A[i]) != 0:
        print(0)
        exit()
    tmp = (A[i] // 2 * tmp) // gcd(A[i] // 2, tmp)
# print(tmp)
ans = 0
print((M-tmp) // (2 * tmp)+1)
# while tmp * moto <= M:
#     ans += 1
#     moto += 2
# print(ans)
    


Measured memory_bytes: 16304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
 int N,Y;
 cin>>N>>Y;
 bool ans=false;
rep(i,N+1){
    rep(j,N+1){
         int k=N-i-j;
      		if(0<=k){
            if(i*10000+j*5000+k*1000==Y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                ans=true;
              	i+=N;
              	j+=N;
              k+=N;
              break;
            }
            }
        }
    }

 if(ans==false){
     cout<<-1<<" "<<-1<<" "<<-1<<endl;
 }
}


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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
vector<pii> v;
vint w;
pii foo(int x){
	if(v[x].F==x) return v[x];
	pii t=foo(v[x].F);
	return v[x]=mkp(t.F,v[x].S+t.S);
}

void mainmain(){
	int n,m;
	while(cin>>n>>m,n||m){
		v=vector<pii>(n);
		w=vint(n);
		rep(i,n){
			v[i]=mkp(i,0);
			w[i]=0;
		}
		// cout<<"hoge";
		rep(i,m){
			char t;
			cin>>t;
			if(t=='!'){
				int a,b,r;
				cin>>a>>b>>r;
				rep(i,n){
				}
				// cout<<a<<" "<<b<<" "<<r<<endl;
				pii c=foo(a-1),d=foo(b-1);
				// cout<<c.F<<endl;
				if(w[c.F]<w[d.F]){
					v[c.F]=mkp(d.F,d.S-c.S-r);
				}
				else{
					v[d.F]=mkp(c.F,c.S-d.S+r);
					if(w[c.F]==w[d.F]){
						w[c.F]++;
					}
				}
			}
			else{
				int a,b;
				cin>>a>>b;
				rep(i,n){
					
				}
				// cout<<a<<" "<<b<<endl;
				pii c=foo(a-1),d=foo(b-1);
				if(c.F==d.F){
					cout<<-c.S+d.S<<endl;
				}
				else{
					cout<<"UNKNOWN\n";
				}
			}
			/*
			cout<<endl<<"--------\n";
			rep(i,n){
				cout<<v[i].F<<" "<<v[i].S<<" "<<w[i]<<endl;
			}
			cout<<"-----------\n";
			*/
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int main(){
    ii(n);
    rep(i, n){
        ii(a);
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                out("DENIED"); return 0;
            }
        }
    }
    out("APPROVED");
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n, p, a, b[2];
	cin >> n >> p;
	b[0] = b[1] = 0;
	lp(n) {
		cin >> a;
		b[a % 2]++;
	}
	ll ans=b[0];
	if (b[1] == 0) {
		if (p == 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	else ans+=(b[1] - 1);
	ll ans2 = pow(2,ans);
	cout << ans2 << endl;
	return 0;
}

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

int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b, a%b);
}

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
 
  int n;
  int64_t i, j, k;
  cin >> n;
  string s;
  cin >> s;
  if(n==1) cout << 0 << endl;
  else if(n==2) cout << 0 << endl;
  else{
  int64_t sum=0;  
  /*for(i=0; i<n-2; i++){
    for(j=i+1; j<n-1; j++){
      for(k=j+1; k<n; k++){
        if(k-j==j-i) sum+=0;
        else if(s.at(i)!=s.at(j)&&s.at(j)!=s.at(k)&&s.at(i)!=s.at(k)) sum+=1;

      }
    }
  }*/
  int64_t r=0, g=0, b=0;
  rep(t, n){
    if(s.at(t)=='R') r++;
    else if(s.at(t)=='G') g++;
    else b++;
  }
  sum = r*g*b;
  int64_t v = 0;
  for(i=0; i<n-2; i++){
    for(j=i+1; j<n-1; j++){
      int64_t p = 2*j -i;
      if(p>=n) v+=0;
      else if(s.at(i)!=s.at(j)&&s.at(j)!=s.at(p)&&s.at(i)!=s.at(p)) v++; 
    }
  }
  cout << sum-v << endl;

  }
  /*int k, n;
  cin >> n >> k;*/
}



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        String line = readLine();
        String subLine;
        if(line.length()%2 == 0){
            subLine = line.substring(0, line.length()-2);
        } else {
            subLine = line.substring(0, line.length()-1);
        }
            
        while(true) {
            int len = subLine.length();
            String before = subLine.substring(0, len / 2);
            String after = subLine.substring(len / 2, len);
            if (before.equals(after)) {
                if (subLine.length() == 0) {
                    System.out.println(1);
                }
                System.out.println(subLine.length());
                return;
            } else {
                subLine = subLine.substring(0, subLine.length() - 2);
            }
        }
    }

    private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)


int main(){
    int a;
    int b;
    
    
    while(true){
        cin >> a >> b;
        
        if(a == 0 && b == 0) break;
        if(a > b) swap(a , b); 
        
        
        cout << a << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 3024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  map<ll, int> MAP;
  FOR(i,0,N) {
    ll in; cin >> in;
    if(MAP[in] == 2) MAP[in] = 1;
    else MAP[in] = 2;
  }
  int ans = 0;
  for(auto m : MAP) if(m.second == 2) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main() {
  int red, blue, green, k;
  int i=0;
  
  scanf("%d%d%d%d", &red, &green, &blue, &k);
  
  while(green<=red || blue<=green) {
    if(green<=red) {
      green = 2*green;
      i++;
    } else if(blue<=green) {
      blue = 2*blue;
      i++;
    }
  }
  
  //printf("%d\n", i);
  
  if(i<=k) {
    printf("Yes");
  } else if(i>k){
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 1720
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#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;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;



int main () {

    int a,b; cin >>a>>b;

    if (a == b) {
        cout << "Draw" << endl;
    } else {
        if (a < b) {
            if (a != 1) {
                cout << "Bob" << endl;
            } else {
                cout << "Alice" << endl;
            } 
        } else {
            if (b != 1) {
                cout << "Alice" << endl;
            } else {
                cout << "Bob" << endl;
            }
        } 
    } 

    return 0;
}




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

int main() {
    int N; cin >> N;
    int max_value = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int p; cin >> p;
        max_value = max(max_value, p);
        ans += p;
    }
    ans -= max_value / 2;
    cout << ans << endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+1;
long dp[MAX][3];
int main()
{
    int n;
    scanf("%d",&n);
    int a[n][3];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 3712
#include <iostream>
#include <map>

using namespace std;
int main() {
	int n;
  	cin >> n;
    map<string, int> cnt;
  	for (int i = 0; i < n; ++i) {
    	string s;
      	cin >> s;
      	cnt[s]++;
    }
    for (string s : {"AC", "WA", "TLE", "RE"}) {
    	cout << s << " x " << cnt[s] << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#include <cmath>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=9;i++){
		for(ll j=1;j<=9;j++){
			if(n==i*j){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	// your code goes here
	return 0;
}

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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a < c){
        if(b - d > 0){
            cout << d - c << endl;
        }
        else if(b - c > 0){
            cout << b - c << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        if(d - b > 0){
            cout << b - a << endl;
        }else if(d - a > 0){
            cout << d - a << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  map<string, bool> mp;
  ll cnt = 0;
  for (ll i = 0; i < N; i++) {
    string s; cin >> s;
    if (!mp[s]) {
      cnt++;
      mp[s] = true;
    }
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 19284
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < d; j++){
		        x[i][j] = sc.nextInt();
		    }
		}
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    for(int j = i+1; j < n; j++){
		        long dist = 0;
		        for(int k = 0; k < d; k++){
		            dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
		        }
		        boolean flg = false;
		        for(int k = 0; k <= sqrt(dist); k++){
		            if(dist == k*k){
		                flg = true;
		                break;
		            } 
		        }
		        if(flg) result++;
		    }
		}

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define int long long
using namespace std;

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

    int n;
    int l[88];
    for(int i = 0; i < 88; i ++){
        l[88] = -1;
    }
    l[0] = 2;
    l[1] = 1;
    cin >> n;
    if(n == 1) cout << 1;
    else {
        for (int i = 2; i <= n; i++) {
            l[i] = l[i-1] + l[i-2];
        }
        cout << l[n];
    }
    return 0;
}









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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

string str, t;
vector <string> vct;

bool match(int i){
    string tp = str;
    for(int j = i, cnt = 0; j < i + t.size(); ++j, ++cnt){
        if(tp[j] == t[cnt]) continue;
        if(tp[j] == '?'){
            tp[j] = t[cnt];
            continue;
        }
        return false;
    }

    for(auto&i:tp){
        if(i == '?') i = 'a';
    }
    vct.pb(tp);
    return true;
}


main(){
    cin >> str >> t;
    bool flag = 0;
    for(int i = str.size() - t.size(); i >= 0; --i){
        match(i);
    }
    if(vct.size() == 0) return puts("UNRESTORABLE"), 0;
    sort(all(vct));
    str = vct[0];
    cout << str << endl;
}


Measured memory_bytes: 256
import bisect
INF = 10 ** 18

A, B, Q = map(int, input().split())

s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
string s;
int ans;
int main()
{
	cin>>s;
	if (s.size()==1 || s=="01" || s=="10")
	{
		cout<<"0";
		return 0;
	}
	if (s[0]=='0')
	{
		int a=0;
		for (int i=0;i<s.size();++i)
			if (i%2==0 && s[i]!='0') ++a;
			else if (i%2==1 && s[i]!='1') ++a;
		int b=0;
		s[0]='1';
		++b;
		for (int i=0;i<s.size();++i)
			if (i%2==0 && s[i]!='1') ++b;
			else if (i%2==1 && s[i]!='0') ++b;
		ans=min(a,b);
	}
	else
	{
		int a=0;
		for (int i=0;i<s.size();++i)
			if (i%2==0 && s[i]!='1') ++a;
			else if (i%2==1 && s[i]!='0') ++a;
		int b=0;
		s[0]='0';
		++b;
		for (int i=0;i<s.size();++i)
			if (i%2==0 && s[i]!='0') ++b;
			else if (i%2==1 && s[i]!='1') ++b;
		ans=min(a,b);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define REP(i,n) for(int i=0; i < n; i++)
#define orta ((bas+son)/2)
#define coc g[node][i].st
#define yol g[node][i].nd
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n, a[N], son, bas, fl;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	scanf("%d",&n);
	REP(i,n)scanf("%d",a+i);
	REP(i,n){
		if(i==0 or a[i-1] < a[i]) a[i]--;
	}
	REP(i,n-1)
		if(a[i] > a[i+1]){
			cout << "No\n";
			return 0;
		}
	cout << "Yes\n";

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair

 int main()
 {
      FASTIO;
      ll k,a,b;
      cin>>k;
      cin>>a>>b;
      ll d;
      if(a%k==0)
      cout<<"OK";
      else
      {
      d=a%k;
      if(b>=k-d+a)
      cout<<"OK";
      else
      cout<<"NG";
      }
      }


Measured memory_bytes: 3648
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  i64 answer = 0;
  for (i64 i = 0; i < N; i += 2) {
    if (a[i] % 2 == 1) ++answer;
  }

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

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

string ans;
int w,h,gx,gy;
int map[110][110];
int dx_[4] = {0,1,0,-1};
int dy_[4] = {1,0,-1,0};
int dx[2][8] = {
	{0,1,2,3,0,1,2,3},
	{0,1,0,1,0,1,0,1}
};
int dy[2][8] = {
	{0,0,0,0,1,1,1,1},
	{0,0,1,1,2,2,3,3},
};
void solve(int x,int y,int color){
	if( ans == "OK" || color == 0 ) return;

	for(int i=0 ; i<4 ; ++i ){
		int mx = x + dx_[i];
		int my = y + dy_[i];
		if( mx<0 || mx>w || my<0 || my>h ) continue;
		
		if( map[my][mx] == color ){
			if( mx == gx && my == gy ){
				ans = "OK";
			}else{
				map[my][mx] = 0;
				solve( mx , my , color );
			}
		}
	}
}

int main(){
	int sx,sy,n;
	
	while( cin >> w >> h , w|h ){
		ans = "NG";
		for(int y=0 ; y<110 ; ++y )
			for(int x=0 ; x<110 ; ++x )
				map[y][x] = 0;

		cin >> sx >> sy >> gx >> gy >> n ;
		for(int i=0 ; i<n ; ++i ){
			int c,d,x,y;
			cin >> c >> d >> x >> y;
			for(int j=0 ; j<8 ; j++){
				int mx = x + dx[d][j];
				int my = y + dy[d][j];
				map[my][mx] = c;
			}
		}
		solve( sx , sy , map[sy][sx] );
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

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

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def multiple(a, b):
    return a*b // euclid(a, b)

def lcm(nums):
        return functools.reduce(multiple, nums)

X = lcm(A)
ans = 0
for i in range(N):
    ans += X//A[i]
ans %= MOD
print(ans)

Measured memory_bytes: 71404
# coding: utf-8
m = []
for i in range(3):
    m.append(list(map(int, input().split())))

# 横の走査
flag = True
l = []
for i in range(2):
    for j in range(1, 3):
        l = []
        for k in range(3):
            l.append(m[i][k] - m[j][k])
        if len(set(l)) != 1:
            flag = False
# 縦の走査
for i in range(2):
    for j in range(1, 3):
        l = []
        for k in range(3):
            l.append(m[k][i] - m[k][j])
        if len(set(l)) != 1:
            flag = False
print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll x,cnt;
    cin>>x;
    cnt=x/11*2; x%=11;
    if(x>0&&x<=6) cnt++;
    else if(x>6&&x<=10) cnt+=2;
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_LEN=2e5,INF=1e6;
string A;

char dp[MAX_LEN+1];
int dp2[MAX_LEN+1];
map<char,int> mp[MAX_LEN+1];

int main(){
	cin>>A;
	A.insert(A.begin(),'$');
	dp[A.size()-1]='a';
	dp2[A.size()-1]=1;
	map<char,int> m;
	for(int i=A.size()-1;i>=0;i--){
		mp[i]=m;
		m[A[i]]=i;
	}
	for(int i=A.size()-2;i>=0;i--){
		dp2[i]=INF;	
		REP(j,'z'-'a'+1){
			if (mp[i].find(j+'a')!=mp[i].end()){	
				if (dp2[i]>dp2[mp[i][j+'a']]+1){
					dp2[i]=dp2[mp[i][j+'a']]+1;
					dp[i]=j+'a';
				}
			}else if (dp2[i]>1){
				dp2[i]=1;
				dp[i]=j+'a';
			}
		}
	}
	char c=dp[0];
	int inx=0;
	do{
		cout<<c;
		if (mp[inx].find(c)==mp[inx].end()){
			break;
		}else{
			inx=mp[inx][c];
			c=dp[inx];
		}
	}while(1);
	cout<<endl;
	return 0;
}

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

int HT[10][10]; //HeadTail

int main(void) {
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			HT[i][j] = 0;
		}
	}
	int N;
	cin >> N;
	for (int i = 1; ((i <= 9) && (i <= N)); i++) {
		HT[i][i]++;
	}
	for (int i = 10; ((i <= 99) && (i <= N)); i++) {
		int h = i/10;
		int t = i%10;
		HT[h][t]++;
	}
	for (int i = 100; ((i <= 999) && (i <= N)); i++) {
		int h = i/100;
		int t = i%10;
		HT[h][t]++;
	}
	for (int i = 1000; ((i <= 9999) && (i <= N)); i++) {
		int h = i/1000;
		int t = i%10;
		HT[h][t]++;
	}
	for (int i = 10000; ((i <= 99999) && (i <= N)); i++) {
		int h = i/10000;
		int t = i%10;
		HT[h][t]++;
	}
	for (int i = 100000; ((i <= 999999) && (i <= N)); i++) {
		int h = i/100000;
		int t = i%10;
		HT[h][t]++;
	}

	long long ans = 0;
	for (int h = 1; h <= 9; h++) {
		for (int t = 1; t <= 9; t++) {
			ans += HT[h][t] * HT[t][h];
		}
	}
	cout << ans << endl;
  return 0;
}



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


int main(){
    int n,A[1000];
    cin >> n;

    for(int i=0;i<n;i++)cin >> A[i];
    for(int i=0;i<n;i++){
        int v=A[i];
        int j=i-1;
        while(j >= 0 && A[j]>v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        
    for(int i=0;i<n;i++){
        if(i== n-1)cout << A[i] << endl;
        else cout << A[i] << " " ;
    }

    }


}


Measured memory_bytes: 3088
# abc143_a.py
# https://atcoder.jp/contests/abc143/tasks/abc143_a

# A - Curtain /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 高橋君の家の窓の横方向の長さは Aであり、横方向の長さが B のカーテンが 2枚取り付けられています。
# (カーテンは縦方向には窓を覆うのに十分な長さがあります。)
# 窓のうちカーテンで隠されていない部分の横方向の長さが最小になるようにカーテンを閉めます。 
# このとき、窓のカーテンで隠されていない部分の合計の横方向の長さを求めてください。

# 制約
#     1≤A≤100
#     1≤B≤100
#     A,Bは整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 窓のうちカーテンで隠されていない部分の合計の横方向の長さを出力せよ。

# 入力例 1
# 12 4

# 出力例 1
# 4

# 横幅 12の窓の、例えば両端からの距離が 4 以内の部分が隠されます。カーテンで隠されない部分の横方向の長さは 4です。

# 入力例 2
# 20 15

# 出力例 2
# 0

# 窓がカーテンで完全に隠される場合は 0と出力してください。

# 入力例 3
# 20 30

# 出力例 3
# 0

# 各カーテンが窓の横幅より長い場合があります。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = max(0, A - 2*B)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['12 4']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['20 15']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['20 30']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

typedef long long ll;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b) cout << c << endl;
  if(b==c) cout << a << endl;
  if(a==c) cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, X, T;
    cin >> N >> X >> T;
    cout << T * (N / X + !!(N % X)) << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
typedef long long ll;

void swap(int* a, int* b) {
	int t = *a;
	*a = *b;
	*b = t;
}

int main() {
	int x, y, z;
	std::cin >> x >> y >> z;
	swap(&x, &y);
	swap(&x, &z);
	std::cout << x << " " << y << " " << z;
	return 0;
}

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

int main(){
  int N, i, j, c = 0;
  
  cin >> N ;

  vector<int> a(N);

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

  sort(a.begin(),a.end(),greater<int>());
  
  for(i=0;i<N;i+=2){
    c += a.at(i);
  }
  for(i=1;i<N;i+=2){
    c -= a.at(i);
  }
  
  cout << c << endl;    

}


Measured memory_bytes: 256
S=input()
x=0
y=0
N = len(S)
for i in range(0,N): # 0,1,2,..., N-1: 
 if S[i]=="0": # S[i]=="0":
       x+=1
 else:
       y+=1

if x>=y:
      print(2*(N-x))
else:
      print(2*(N-y))

#print (S)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long int N , a[100002]={0} ,ans = 0 ,c = 0 , i;
    map < int , int > op , np;
    cin >> N;
    for(i=0;i<N;i++)
    {
        cin >> a[i];
        op[a[i]] = i;
    }
    sort(a,a+N);
    for(i=0;i<N;i++)
    {
        np[a[i]] = i;
        if(abs((np[a[i]] - op[a[i]]))%2 == 1)
            {
                c++;
            }
    }
    ans = c/2 + c%2;
    cout << ans ;
    return 0;
}

Measured memory_bytes: 10368
import itertools
import math
N=int(input())
A=list(itertools.permutations(range(1,N+1)))
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
count_P=0
count_Q=0
p=math.factorial(N)
for i in range(p):
    if P==A[i]:
        count_P=i
    if Q==A[i]:
        count_Q=i
print(abs(count_P-count_Q))

Measured memory_bytes: 7972
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>

int main (void){

    int A,B,C,D;
    scanf("%d %d %d",&A,&B,&C);

    if(A-B >= C){
        D = 0;
    }else if(A-B < C){
        D = C-(A-B);
    }

    printf("%d",D);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  int n, m;
  cin >> n;
  int t[n];
  int ans = 0;
  
  for(int i = 0; i < n; i++){
    cin >> t[i];
    ans += t[i];
  }
  
  cin >> m;
  for(int i = 0; i < m; i++){
    int p, x;
    cin >> p >> x;
    cout << ans - t[p - 1] + x << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int D;
  cin>>D;
  if(D==22)
    cout<<"Christmas Eve Eve Eve"<<endl;
  if(D==23)
    cout<<"Christmas Eve Eve"<<endl;
  if(D==24)
    cout<<"Christmas Eve"<<endl;
  if(D==25)
    cout<<"Christmas"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    int64_t sum = 0;
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
        sum += vec[i];
    }

    int64_t sum_price = 0;
    int64_t min_sa = INT64_MAX;
    int64_t now = 0;
    for (int64_t i=0; i<N; i++) {
        now += vec[i];
        int64_t sa = abs((sum - now) - now);
        if (min_sa >  sa) {
            min_sa = sa;
        }
    }

    cout << min_sa << endl;
    return 0;
}

Measured memory_bytes: 4760
#include <cstdio>

int main(){
	double l, r;
	int lA, lB, lC, lD;
	int rA, rB, rC, rD;
	
	lA = lB = lC = lD = 0;
	rA = rB = rC = rD = 0;
	
	while(scanf("%lf %lf", &l, &r) != EOF){
		if(l >= 1.1){
			lA++;
		}else if(l >= 0.6){
			lB++;
		}else if(l >= 0.2){
			lC++;
		}else {
			lD++;
		}
		if(r >= 1.1){
			rA++;
		}else if(r >= 0.6){
			rB++;
		}else if(r >= 0.2){
			rC++;
		}else {
			rD++;
		}
	}
	
	printf("%d %d\n%d %d\n%d %d\n%d %d\n", lA, rA, lB, rB, lC, rC, lD, rD);
	
	return 0;
}
	

Measured memory_bytes: 1056