akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

// ?????§????§£????????????????????????
class MaxFlow{
private:
  // edge: ??£??\??????????????? (to: ?????????, cap: ??????, rev: ???????????????(G[to][rev]?????????))
  // G: ??£??\?????????, used: ?????¨???????????????
  struct edge{
    int to, cap, rev;
    edge(int to_, int cap_, int rev_){ to = to_; cap = cap_; rev = rev_; }
  };
  vector<vector<edge> > G;
  vector<bool> used;
  int dfs(int v, int t, int f);
public:
  // ?????????????????????
  MaxFlow(int size){
    G = vector<vector<edge> >(size);
    used = vector<bool>(size);
  }
  void add_edge(int from, int to, int cap);
  int flow(int s, int t);
};

// ????????????
void MaxFlow::add_edge(int from, int to, int cap){
  G[from].push_back(edge(to, cap, G[to].size()));
  G[to].push_back(edge(from, 0, G[from].size() - 1));
}

// ??±???????????¢?´¢??§?¢???????????????¢???
// v: ?????¨??°???, t: ??????, f: ???????????????
int MaxFlow::dfs(int v, int t, int f){
  if(v == t){ return f; }
  used[v] = true;

  for(int i = 0; i < G[v].size(); i++){
    edge &e = G[v][i];
    // ???????????????????????????????????????????????????????????????????????????????????£????????????
    if(!used[e.to] && e.cap > 0){
      // ????????????????????°??????dfs
      int d = dfs(e.to, t, ((f < e.cap) ? f : e.cap));
      // ??????1ml??§??????????????????????????????
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  
  return 0;
}

// s??????t?????§????????§???????±???????
int MaxFlow::flow(int s, int t){
  int flow = 0;
  while(true){
    for(int i = 0; i < used.size(); i++)
      used[i] = false;
    int f = dfs(s, t, 1e9);
    if(f == 0){ return flow; }
    flow += f;
  }
}

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


int main(void){
  while(true){
    int m, n;
    cin >> m >> n;
    if(m == 0 && n == 0){ break; }

    // ??????????????£?¨?
    MaxFlow f(m + n + 2);

    // ???????????????????????????????????????
    vector<int> b(m);
    for(int i = 0; i < m; i++){
      cin >> b[i];
      // ?§?????????????????????????????????°???
      f.add_edge(0, 1 + i, 1);
    }

    // ???????????????????????????????????????
    int r;
    for(int i = 0; i < n; i++){
      cin >> r;
      for(int j = 0; j < m; j++){
        // ???????????§??¬?´???°???1????????§???????????°?????????????????????????????????????????°???
        if(gcd(r, b[j]) > 1){ f.add_edge(1 + j, 1 + m + i, 1); }
      }
      // ???????????????????????????????????°???
      f.add_edge(1 + m + i, 1 + m + n, 1);
    }

    // ?????§???????±?????????????
    cout << f.flow(0, 1 + m + n) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<cfloat>
#include<cmath>
#include<algorithm>


using namespace std;

double EPS = 1e-10;


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

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

bool Binary_search(vector<point>N, point x){
  int l=0,r=N.size(),mid=(l+r)/2;

  while(r-l>1){
    if(N[mid]==x)return true;

    if(x.x < N[mid].x ||(N[mid].x==x.x && x.y < N[mid].y))r=mid;
    else l=mid;

    mid=(l+r)/2;
  } 

  if(N[mid]==x)return true;
  return false;
}

point solve(vector<point> M, vector<point> N){

  for(int i=0; i< N.size(); i++){
    int j=1;
    for(; j< M.size(); j++){
      point t=N[i]+M[j]-M[0];
      if(!Binary_search(N,t))break;   
    }
    if(j==M.size())return N[i]-M[0];
  }
  return M[0];
}

int main(void){
  int n,m;
  point in;
  vector<point>M,N;

  while(cin >> m,m){
    M.clear();
    N.clear();    

    for(int i=0; i< m; i++){
      cin >> in.x >> in.y;
      M.push_back(in);
    }
    
    cin >> n;

    for(int i=0; i< n; i++){
      cin >> in.x >> in.y;
      N.push_back(in);
    }

    sort(N.begin(),N.end(),cmp_x);

    point res=solve(M,N);

    cout << res.x <<" "<< res.y << endl;

  } 

  return 0;
}

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

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, K, A[5005];

bool dp[5005][5005];

bool need(int t)
{
    CLR(dp);
    dp[0][0] = true;
    REPS(i, N)
    {
        int a = A[i - 1];
        FOR(j, 0, K)
        {
            if (i == t)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else if (j - a < 0)
            {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            else
            {
                dp[i][j] = dp[i - 1][j - a] || dp[i - 1][j];
            }
            if (dp[i][j] && j >= K - A[t - 1] && j < K)
                return true;
        }
    }
    return false;
}

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

    cin >> N >> K;
    REP(i, N)
    {
        cin >> A[i];
    }
    sort(A, A + N);

    if (!need(N))
    {
        cout << N << endl;
        return 0;
    }

    int left = 0;
    int right = N;
    while (right - left > 1)
    {
        int mid = (left + right) / 2;
        if (need(mid))
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }
    cout << left << endl;

    return 0;
}


Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define ninf -2147483648
#define INF 1e9    

#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 





int a[300005];
bool b[105];
char c[1000005];

long long prime[1000000];

 void sieve()
 {

        for(int i=2;i<1000000;i++)
            prime[i]=1;
        
        prime[1]=0;
        prime[0]=0;
    
        for(int i=2;i * i<1000000;i++)
        {
            if(prime[i]==1)
            {
                for(int j=i * i;j<1000000;j+=i)
                {
                    prime[j]=0;
                }
            }
        }

 }




int main() {
    fastio();
    //int t;cin>>t;
    sieve();
    int n;
    cin>>n;
    
    if(n<10)
    {    cout<<"Yes";
         return 0;   
    }
    bool check = false;
    for(int i=1;i<=9;++i)
    {
        for(int j=1;j<=9;++j){
            
            if(i*j==n)
            {
                check = true;
                break;
            }
        }
        if(check){
            break;
        }
    }
    
    if(check == true)
        cout<<"Yes";
    else
        cout<<"No";
    
    
return 0;
}
 


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



int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
   */
    int n,m;
    cin>>n>>m;
    vector<long long int>dp((1<<n),INT_MAX);
    dp[0]=0;
    while(m--)
    {
      int a,b;
      cin>>a>>b;
      int t=0;
      while(b--)
      {
        int num;
        cin>>num;
        t|=(1<<(num-1));
      }

      auto ndp=dp;
      for(int i=0;i<(1<<n);i++)
      {
        if(dp[i]<INT_MAX)
        {
          ndp[(i|t)]=min(ndp[(i|t)],dp[i]+a);
        }
      }

      swap(dp,ndp);
    }

    if(dp.back()<INT_MAX)
    cout<<dp.back()<<endl;
    else
    cout<<"-1"<<endl;  

       return 0;
    
}

Measured memory_bytes: 3708
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
matrixC = [ [ sum( matrixA[i][k] * matrixB[k][j]  for k in range( m ) ) for j in range( l ) ] for i in range( n )  ]

for i in range( n ):
	print( " ".join( map( str, matrixC[i] ) ) )

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

int main()
{
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  string result = A1 + A2 + A3 > 21 ? "bust" : "win";
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define upper_index(v,a) (int)distance(v.begin(), upper_bound((v).begin(),(v).end(),a))
#define lower_index(v,a) (int)distance(v.begin(), lower_bound((v).begin(),(v).end(),a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
typedef long long ll;
const ll INF=1e18;
const ll MOD=1e9+7;

int main(){
    int N,D,A;cin>>N>>D>>A;
    vector<pair<int,int>> E(N);rep(i,N) cin>>E[i].first>>E[i].second;
    sort(E.begin(),E.end());
    vector<int> locate(N); rep(i,N) locate[i]=E[i].first;
    vector<int> imos(N+5,0);
    ll res=0;
    rep(i,N){
        imos[i+1]+=imos[i];
        if(imos[i+1]<E[i].second){
            int damage=((E[i].second-imos[i+1]+A-1)/A)*A;
            imos[i+1]+=damage;
            if (!(E[N-1].first<=E[i].first+2*D)) imos[upper_index(locate,E[i].first+2*D)+1]-=damage;
            res+=damage/A;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3328
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


N = int(input())
x = math.floor(N/3)
print(x)

Measured memory_bytes: 13092
#include<iostream>
#include<queue>
#include<vector>
#include<cmath>

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

const int INF = 1001001001;


int main(){
	int k;cin >> k;
	priority_queue<ll, vector<ll>, greater<ll>> q;
	int cnt = 0;
	ll node;
	int last;

	rep(i,9)q.push(i+1);
	while(1){
		node = q.top();q.pop();
		++cnt;
		if(cnt == k){
			cout << node << endl;return 0;
		}
		last = node % 10;
		if(last == 0){
			q.push(node * 10);
			q.push(node * 10 + 1);
		}else if(last == 9){
			q.push(node * 10 + 9);
			q.push(node * 10 + 8);
		}else{
			q.push(node * 10 + last - 1);
			q.push(node * 10 + last);
			q.push(node * 10 + last + 1);
		}
		
	}

	return 0;
}


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

int dp[2000][2000];

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  while(n--){
    string sa, sb; cin >> sa >> sb;
    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= sa.size(); i++){
      for(int j = 1; j <= sb.size(); j++){
        if(sa[i-1] == sb[j-1]){
          dp[i][j] = dp[i-1][j-1] + 1;
        }else{
          dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
      }
    }
    cout << dp[sa.size()][sb.size()] << endl;
  }
  return 0;
}

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

using namespace std;
using lli=long long int;

int main(){
  lli n, z, w;
  cin >> n >> z >> w;
  vector<lli> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  cout << max(abs(n > 1 ? a[n-1] - a[n-2] : 0), abs(w-a[n-1])) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int a,b,c,d;
int ans[510];
signed main(){
	cin>>a>>b>>c>>d;
	if(a%c==0&&b%d==0){
		puts("No");
		return 0;
	}
	puts("Yes");
	bool flag=false;
	if(a%c==0){
		swap(a,b);
		swap(c,d);
		flag=true;
	}
	ans[a]=10000;
	for(int i=a-1;i>=0;i--){
		if(i+c<=a)ans[i]=ans[i+c]+1;
		else ans[i]=ans[i-1]-1;
	}
	if(flag){
		rep(i,b){
			for(int j=1;j<=a-1;j++)cout<<ans[j]-ans[j-1]<<" ";
			cout<<ans[a]-ans[a-1]<<endl;
		}
	}
	else{
		for(int i=1;i<=a;i++){
			rep(j,b-1)cout<<ans[i]-ans[i-1]<<" ";
			cout<<ans[i]-ans[i-1]<<endl;
		}
	}
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.size();

    string ans = "Yes";

    for(int i = 0;i < N;i++){
        if(S[i] != S[N - 1 - i])
            ans = "No";
    }
    for (int i = 0; i <= (N - 1) / 4;i++)
    {
        if(S[i] != S[(N-1)/2 - i - 1])
            ans = "No";
    }
    for (int i = 0; i <= (N - 1) / 4;i++){
        if(S[i + (N + 3) / 2 - 1] != S[N - 1 - i])
            ans ="No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
dice = list(map(int, input().split()))
directions = input()

for direction in directions:
    if direction == 'N':
        dice = [dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]]
    elif direction == 'S':
        dice = [dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]]
    elif direction == 'W':
        dice = [dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]]
    else:
        dice = [dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]]

print(dice[0])


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int b=0;
	for(int i=0;i<a.size();i++)
	{
	if(a[i]=='+')b++;
	if(a[i]=='-')b--;
	}
	cout<<b;
	return 0;
}

Measured memory_bytes: 256
package main

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

const TOO_FAR = int64(50000000000)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nShrines := scanInt(sc)
	nTemples := scanInt(sc)
	nQuestions := scanInt(sc)

	shrines := make([]int64, nShrines+2)
	for i := 1; i <= nShrines; i++ {
		shrines[i] = int64(scanInt(sc))
	}
	shrines[0] = -TOO_FAR
	shrines[nShrines+1] = TOO_FAR

	temples := make([]int64, nTemples+2)
	for i := 1; i <= nTemples; i++ {
		temples[i] = int64(scanInt(sc))
	}
	temples[0] = -TOO_FAR
	temples[nTemples+1] = TOO_FAR

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < nQuestions; i++ {
		x := int64(scanInt(sc))
		shrineL, shrineR := findNearestMoves(x, shrines)
		templeL, templeR := findNearestMoves(x, temples)
		minMove := calcMinMove(shrineL, shrineR, templeL, templeR)
		fmt.Fprintln(w, minMove)
	}
	w.Flush()
}

func findNearestMoves(p int64, ns []int64) (int64, int64) {
	l := 0
	r := len(ns) - 1
	for r-l > 1 {
		m := (l + r) / 2
		if ns[m] < p {
			l = m
		} else {
			r = m
		}
	}
	return p - ns[l], ns[r] - p
}

func calcMinMove(shrineL, shrineR, templeL, templeR int64) int64 {
	return min(
		max(shrineL, templeL),
		max(shrineR, templeR),
		minRoundTrip(shrineL, templeR),
		minRoundTrip(templeL, shrineR),
	)
}

func minRoundTrip(left, right int64) int64 {
	if left < right {
		return left*2 + right
	}
	return left + right*2
}

func min(ns ...int64) int64 {
	m := int64(math.MaxInt64)
	for _, n := range ns {
		if n < m {
			m = n
		}
	}
	return m
}

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

func abs(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string s;
	bool a1=false,a2=false;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(!a1){
			if(s[i]=='C'){
				a1=true;
			}
		}
		if(a1){
			if(s[i]=='F'){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int d;
  cin >> d;
  string ans;
  if(d == 22) ans = "Christmas Eve Eve Eve";
  if(d == 23) ans = "Christmas Eve Eve";
  if(d == 24) ans = "Christmas Eve";
  if(d == 25) ans = "Christmas";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        x: i64,
    }
    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
    // println!("{}", );
}


Measured memory_bytes: 2164
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()

t = ''
prev = ''
ans = 0
for c in S:
    t += c
    if t != prev:
        prev = t
        t = ''
        ans += 1
if t:
    if t != prev:
        ans += 1
print(ans)


Measured memory_bytes: 13948
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    string str;
    cin >> str;
    n = str.size();
    i = 0, j = n - 1;

    ll ans = 0;

    while(i<j){
        if(str[i]!=str[j]){
            ans++;
        }
        i++;
        j--;
    }


    cout<<ans;
    return 0;
}




Measured memory_bytes: 3632
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(ll i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define pi 3.1415926535897932384626433832795028841971
#define mem(a,b) memset(a , b , sizeof a ) ;
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
//cout<<fixed<<setprecision(15);
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
void solve()
{
	ll n;
	cin>>n;
	scan(n);
	ll ans=a[0];
	for(ll i=1;i<n;i++)
	{
		ans^=a[i];
	}
	ll b[n];
	for(ll i=n-1;i>=0;i--)
	{
		ans^=a[i];
		b[i]=ans;
		ans^=a[i];
	}
	/*ans=a[n-1];
	for(ll i=n-2;i>0;i--)
	{
		ans^=a[i];
	}
	b[0]=ans;*/
	print(b,n);
}
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/




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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());

            Console.WriteLine(n * n - m);
        }
    }
}


Measured memory_bytes: 13140
from collections import defaultdict

dic = defaultdict(int)

N = int(input())
for _ in range(N):
  dic[input()] += 1
  
mmax = max(dic.values())
for k, v in sorted(dic.items(), key=lambda x:x[0]):
  if v == mmax:
    print(k)
  else:
    continue

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,M,X; cin>>N>>M>>X;
  vector<ll> C(N);
  vector<vector<ll>> A(N,vector<ll> (M));
  rep(i,N){
    cin>>C.at(i);
    rep(j,M)cin>>A.at(i).at(j);
  }
  ll res = -1;
  for(int bit = 1; bit < (1<<N); bit++){
    ll tmp = 0;
    vector<ll> tmpA(M,0);
    for(int i = 0; i < N; i++){
      if(bit&(1<<i)){
        tmp+=C.at(i);
        rep(j,M)tmpA.at(j)+=A.at(i).at(j);
      }
      int flag = 0;
      rep(j,M)if(tmpA.at(j)<X){
        flag = 1;
        break;
      }
      if(!flag){
        if(res==-1)res=tmp;
        else res=min(res,tmp);
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<>();
		StringBuilder sb = new StringBuilder();
		int count = 0;
		for (int i = 0; i < n; i++) {
		    int type = sc.nextInt();
		    int x = sc.nextInt();
		    if (type == 0) {
		        if (map.containsKey(x)) {
		            map.put(x, map.get(x) + 1);
		        } else {
		            map.put(x, 1);
		        }
		        count++;
		        sb.append(count).append("\n");
		    } else if (type == 1) {
		        if (map.containsKey(x)) {
		            sb.append(map.get(x));
		        } else {
		            sb.append(0);
		        }
		        sb.append("\n");
		    } else if (type == 2) {
		        if (map.containsKey(x)) {
		            count -= map.get(x);
		            map.remove(x);
		        }
		    } else {
		        int y = sc.nextInt();
		        Integer tmp = x - 1;
		        while ((tmp = map.higherKey(tmp)) != null && tmp <= y) {
		            for (int j = 0; j < map.get(tmp); j++) {
		                sb.append(tmp).append("\n");
		            }
		        }
		    }
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 197852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
import bisect
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a_acc = [0] + list(accumulate(A))
b_acc = list(accumulate(B))
ans = 0
for i in range(N+1):
  rem = K - a_acc[i]
  if rem < 0:
    break
  bn = bisect.bisect_right(b_acc,rem)
  ans = max(ans, i+bn)
print(ans) 
  
  
  
  

Measured memory_bytes: 49128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<pair<int,int>> g(n-1);
    rep(i,n-1) {
        cin >> g[i].first >> g[i].second;
    }
    ll ans = 0;
    for(ll l = 1; l <= n; l++) {
        ans += (n-l+1)*(n-l+2)/2;
    }

    rep(i,n-1) {
        int l = min(g[i].first,g[i].second);
        int r = max(g[i].first,g[i].second);
        ans -= (n-r+1) * l;
    }
    cout << ans << endl;

}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 10001
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define P pair<int,int>
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
/*chrono::system_clock::time_point  start;
void timerstart(){start = chrono::system_clock::now();}
void timerend(){
	auto end = chrono::system_clock::now();
	int elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
	printf("%d[ms]\n", elapsed);
}*/

string s, t;
int dp[2003][2003][3];
int main(){
	int n, m;
	cin >> n >> m >> s >> t;
	s = ' ' + s +  'x';t = ' ' + t + 'x';
	
	int ans = 0;
	for(int i = n+1;i >= 1;i--){
		for(int j = m+1;j >= 1;j--){
			if(s[i-1] == 'I'){
				dp[i-1][j][1] = max(dp[i-1][j][1], dp[i][j][2]+1);
			}
			if(t[j-1] == 'I'){
				dp[i][j-1][1] = max(dp[i][j-1][1], dp[i][j][2]+1);
			}
			if(s[i-1] == 'O'){
				if(dp[i][j][1] != 0)
				dp[i-1][j][2] = max(dp[i-1][j][2], dp[i][j][1]+1);
			}
			if(t[j-1] == 'O'){
				if(dp[i][j][1] != 0)
				dp[i][j-1][2] = max(dp[i][j-1][2], dp[i][j][1]+1);
			}
			ans = max(ans, dp[i][j][1]);
		}
	}
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 50304
import java.util.Scanner;
public class Main {
    static final char APPLE_CHAR = '@';
    static final char KAKI_CHAR = '#';
    static final char ORANGE_CHAR = '*';
    static final char CHECKED = '0';
    char area[][];
    char fruit;
    void run(){
        Scanner scan = new Scanner(System.in);
        while(true){
            int h = scan.nextInt();
            int w = scan.nextInt();
            if(h == 0 && w == 0)break;
            area = new char[h][w];
            for(int i = 0;i < h;i++){
                String col = scan.next();
                for(int j = 0;j < w;j++){
                    area[i][j] = col.charAt(j);
                }
            }
            int groupCnt = 0;
            for(int i = 0;i < h;i++){
                for(int j = 0;j < w;j++){
                    //??????§???????????????????????????
                    if(area[i][j] == CHECKED)continue;
                    groupCnt++;
                    fruit = area[i][j];
                    checkArea(i,j);
                }
            }
            System.out.println(groupCnt);
        }
    }
 
    //???£??¶?????????????????????????°??????§????????????
    void checkArea(int y,int x){
        //????????????NG
        if(y >= area.length)return;
        if(y < 0)return;
        if(x >= area[0].length)return;
        if(x < 0)return;
        if(area[y][x] == fruit){
            area[y][x] = CHECKED;
            checkArea(y + 1,x    );
            checkArea(y - 1,x    );
            checkArea(y    ,x + 1);
            checkArea(y    ,x - 1);
        }
    }
 
    public static void main(String args[]){
        new Main().run();
    }
}

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

int main(){
  int n;
  cin>>n;
  while(n--){
    int r,t;
    cin>> r >> t;
    if(r%100==0&&t%30==0)cout << r/100+(t/30)*5<<endl;
    else if(r%100==0) cout << r/100+(t/30)*5<<" "<<r/100+(t/30)*5+5<<endl;
    else if(t%30==0) cout << r/100+(t/30)*5<<" "<<r/100+(t/30)*5+1<<endl;
    else cout << r/100+(t/30)*5<< " "<<r/100+(t/30)*5+1<<" "<<r/100+(t/30)*5+5<<" "<<r/100+(t/30)*5+6<<endl;
  }
  return 0;
}

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

int main(){
    bool A=1;
    while(A){
        int H,W;
        cin >> H >> W;
        if (H==0 && W==0) {A=0;}
        else {
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if (j==W-1) {cout << "#" << endl;}
                    else {cout << "#";}
                }
                if (i==H-1) {cout << endl;}
            }
        }
    }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
         int a,b,m,sum,sum2,mins,ans;
         cin>>a>>b>>m;
         int x[a],y[b],m0,m1,d,i,j,min1,min2,mad1,mad2;
         for(i=0;i<a;i++)
         {
                  cin>>x[i];
         }
         for(i=0;i<b;i++)
         {
                  cin>>y[i];
         }
         mad1=1;
         mad2=1;
         min1=x[0];
         min2=y[0];
         for(i=0;i<a;i++)
         {
                  if(x[i]<min1)
                  {
                           min1=x[i];
                           mad1=i+1;
                  }
         }
          for(i=0;i<b;i++)
         {
                  if(y[i]<min2)
                  {
                           min2=y[i];
                           mad2=i+1;
                  }
         }
         sum=min1+min2;
         ans=sum;
         for(i=0;i<m;i++)
         {
                  cin>>m0>>m1>>d;
                  sum2=x[m0-1]+y[m1-1]-d;
                  if(sum2<ans)ans=sum2;

         }
         cout<<ans<<endl;

}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    x = list(map(int, input().split()))
    l = []
    for p in range(1, 101):
        r = 0
        for i in range(n):
            r += (x[i] - p) ** 2
        l.append(r)
    print(min(l))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define p2 pair<lo,lo>
#define p3 pair<pair<lo,lo>,lo>
#define p4 pair<pair<lo,lo>,pair<lo,lo> >
#define st first
#define nd second
using namespace std;
typedef long long int lo;
const int N=500005,mod=1000000007;
lo a,b,c,d,e,f,g,h[N],arr[N];
string s;
vector<lo>v;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    cin >> a;
    for(lo i=1;i<=a;i++){
    	cin >> arr[i];
    	if(arr[i]%2==0 and arr[i]%3!=0 and arr[i]%5!=0){
    		cout << "DENIED" << endl;
    		return 0;
    	}
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  string t;
  for(int i=0;i<s.size();i++){
    if(s.at(i) == 'B'){
      if(t.size() !=0){
        t.erase(t.size()-1);
      }
    }
    else t += s.at(i);
  }
  cout << t << endl;
}

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

void solve(long long N, std::vector<long long> A){
    ll ans = A[0];
    rep(i, N)
    {
        ans = __gcd(ans, A[i]);
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)

using namespace std;

const int INF=1<<30;

const int maxn=100000+10;

int pos[maxn];

int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
	int n,x;cin>>n>>x;
	
	int ans=-1;
	rep(i,1,n) {
		scanf("%d",pos+i);
		if(ans==-1) ans=abs(pos[i]-x);
		else ans=gcd(ans,abs(pos[i]-x));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討
teisu = n*(n+1)//2
for i in range(k,n+2):
  ans += teisu-(n-i)*(n-i+1)//2-(i-1)*(i)//2 + 1
  ans%=mod
  # print(i,ans)
print(ans%mod)

  

Measured memory_bytes: 216544
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	string s, t;
	cin >> s >> t;
	if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+10;
ll ans[2];
int main()
{
    int n,p;
    cin>>n>>p;
    ans[0]=1;
    while(n--)
    {
        int z;
        cin>>z;
        z%=2;
        if(z==0)ans[0]*=2,ans[1]*=2;
        else ans[0]=ans[1]=ans[0]+ans[1];
    }
    cout<<ans[p];
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			String s;
			String s1;
			int n;
			int index;
			int index2;
			int result=0;
			Map <Integer,Integer> map = new HashMap<Integer,Integer> ();

			s = sc.next();
			n=s.length();
			sc.close();

			for(index=0;index<n;index++) {
				s1 = s.substring(index,index+1);
				if(index%2==0 && s1.contentEquals("1")) {
						result++;
					}
				else if(index%2==1 && s1.contentEquals("0")) {	
					result++;
					}
				}
			if(result>n-result) {
				result=n-result;
				}
			
			// 出力

			System.out.println(result);
	}
}

Measured memory_bytes: 31028
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(),s.end()
#define fp(x) fixed<<setprecision(x)<<
template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}
int digit(int a)
{
int r;
r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
return r + 1;
}
int main(){
    quickie;
    //txt;
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    int dx = tx - sx;
    int dy = ty - sy;
    cout<<string(dx,'R')<<string(dy,'U');
    cout<<string(dx,'L')<<string(dy,'D');
    cout<<'D'<<string(dx+1,'R')<<string(dy+1,'U')<<'L';
    cout<<'U'<<string(dx+1,'L')<<string(dy+1,'D')<<'R';
    
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, m;
    cin >> n >> m;
    
    if (n == 1 && m == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    if (n == 1) {
        cout << m - 2 << endl;
        return 0;
    }
    
    if (m == 1) {
        cout << n - 2 << endl;
        return 0;
    }
    
    cout << (n - 2) * (m - 2) << endl;
}


Measured memory_bytes: 256
N = int(input())
H = [int(h) for h in input().split()]

if N == 1:
    ans = "Yes"
else:
    c = 0
    while c <= N-2:
        if H[c] < H[c+1]:
            H[c+1] -= 1
        c += 1
    List = []
    for j in range(N):
        List.append(H[j])
    List.sort()
    if List == H:
        ans = "Yes"
    else:
        ans = "No"

print(ans)

Measured memory_bytes: 15300
def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    *s, = map(lambda x: x.count("1"), zip(*a))
    for _s in s:
        ans <<= 1
        ans += _s * (n - _s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

int main(){
  int a[10];
  int tmp;
  int n = 0;

  while(n<10){
    cin >> a[n];
    n++;
  }

  int i,j;

  //降順ソート
  for(i = 0;i < 10;i++){
    for(j = i+1;j < 10;j++){
      if(a[i] < a[j]){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }

  //結果の表示
  for(i = 0;i < 3;i++){
    cout << a[i] << endl;
  }
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    stack<int> st;
    int res=0;
    for(int i=0;i<n;i++){
        if(!st.empty() && st.top()!=s[i]){
            res+=2;
            st.pop();
        }
        else st.push(s[i]);
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,s=0;
  cin>>n;
  for(int i=0;i<n;i++) {
    int a;
    cin>>a;
    s+=a;
  }
  if(s%2) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

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

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

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

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

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, a, b);
    bool f[5] {};
    f[a] = f[b] = true;

    if (f[1] == false) print(1);
    if (f[2] == false) print(2);
    if (f[3] == false) print(3);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define MAX_VAL 110000
#define INF 4123456789123456

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

struct edge{ll to, cost;};

vector<edge> G[MAX_VAL];
ll d[MAX_VAL], V;

void dijkstra(ll s){
	priority_queue<P,vector<P>,greater<P>> q;
	fill(d,d+V, INF);
	
	d[s] = 0;
	q.push(P(0,s));
	
	while(!q.empty()){
		P p = q.top();q.pop();
		ll v = p.second;
		
		if(d[v] < p.first) continue;
		
		for(edge e : G[v]){
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	
	
}

int main(){
	int u, k, v, c;
	cin>>V;
	
	for(int i = 1; i <= V; i++){
		cin>>u>>k;
		for(int j = 1; j <= k; j++){
			cin>>v>>c;
			edge  e = {v,c};
			G[u].push_back(e);
		}
	}
		dijkstra(0);
	for(int i = 0; i < V; i++){
		cout<<i<<" "<<d[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int main()
{
	int n;
	scanf("%d", &n);
	vector <int> A(n), B(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &A[i]);
		B[i] = abs(i - (n - 1 - i));
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	long long int ans = 1;
	int ctr = 1, val = -1;
	for (int i = 0; i < n; ++i)
	{
		if(A[i] != B[i])
		{
			printf("0\n");
			return 0;
		}
		if(A[i] != val)
		{
			ans = (ans*ctr)%MOD;
			ctr = 1;
			val = A[i];
		}
		else
			ctr++;
	}
	ans = (ans*ctr)%MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
def main():
    n=int(input())
    dp=[0]*(3)
    for _ in range(n):
        dp1=[0]*3 
        nums=list(map(int,input().split()))
        for i in range(3):
            for j in range(3):
                if i!=j:
                    dp1[j]=max(dp1[j],dp[i]+nums[j])
            
        dp=dp1
    print( max(dp[0],dp[1],dp[2]))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<cstdio>
#include<map>
#include<string>
#include<iostream>

int n, ans;
std::string s;
std::map<std::string, int> m;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		std::cin >> s;
		++m[s];
	}
	
	std::map<std::string, int>::iterator it = m.begin();
	while(it != m.end()) ++it, ++ans;
	
	printf("%d", ans);
}

Measured memory_bytes: 19396
#include <stdio.h>

int main(void)
{
	int n, i;
	float x1, y1,
		  x2, y2,
		  x3, y3,
		  x4, y4;
	float gra, gra2;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		
		gra  = (y2 - y1) / (x2 - x1);
		gra2 = (y4 - y3) / (x4 - x3);
		
		if (gra == gra2){
			printf("YES");
		}
		else {
			printf("NO");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 624
s = input()
t = input()

flag = False
idx = 0

for i in range(len(s)-len(t)+1):
    if flag == True:
        break
    for j in range(len(t)):
        if s[len(s)-1-i-j] == '?' or s[len(s)-1-i-j] == t[len(t)-1-j] :
            if j == len(t)-1:
                flag = True
                idx = i
                break
        else:
            break
        
if flag == False:
    print('UNRESTORABLE')
    exit()
    
ans = []
num = 0

for i in range(len(s)):
    if len(s)-1-idx >= i and len(s)-1-idx-len(t)+1 <= i:
        ans.append(t[num])
        num += 1
        #print(num,len(s)-1-idx,len(s)-1-idx-len(t)+1,ans)
    elif s[i] == '?':
        ans.append('a')
    else:
        ans.append(s[i])
#s[1] = '1'
print(*ans,sep='')

Measured memory_bytes: 3064