akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF (1e9)
#define int long long
#define MAX_V 5010
#define N MAX_V
using namespace std;

struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

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

int 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) {
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap +=d;
	return d;
      }	
    }
  }
  return 0;
}


int max_flow(int s,int t){
  int flow = 0;
  
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,INF);//////////
    if(f == 0) return flow;
    flow += f;
    if(flow>10001) return flow;
  }
}

int Flow(int s,int t){
  memset(used,0,sizeof(used));
  int f = dfs(s,t,1);//////////
  return f;
}


int visited[N];

void visit(int pos){
  
  if(visited[pos]++) return ;
  
  for(int i=0;i<G[pos].size();i++){
    edge e = G[pos][i];
    if(e.cap == 0) continue;
    visit(e.to);
  }
}

map<int,int> G2[N];
signed main(){
  int n,m;
  cin>>n>>m;

  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    add_edge(a,b,c);
    G2[a][b] = G2[b][a] = c;
  }

  int ans = max_flow(0,n-1);
  
  bool use1=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<G[i].size();j++){
      edge &e = G[i][j];
      if(G2[i][e.to] != 1 || e.cap != 0) continue;
      edge  &re = G[e.to][e.rev];
      e.cap = re.cap = 0;
      if(Flow(i,e.to) == 0)use1 = 1;
      else e.cap = re.cap = 1;
    }
  
  ans -= use1;
  if(ans > 10000) ans = -1;
  cout<<ans<<endl;
}

Measured memory_bytes: 4652
<?php
list($n,$m,$x)=explode(" ",trim(fgets(STDIN)));
$sum=array_fill(1,$m,0);
$i=0;
while($i<$n){
  $s[]=explode(" ",trim(fgets(STDIN)));
  $j=1;
  while($j<=$m){
    $sum[$j]+=$s[$i][$j];
    ++$j;
  }
  ++$i;
}
$p=array_fill(1,pow(2,$n)-1,array_fill(0,$m+1,0));
$ans=100000000;
$i=1;
while($i<pow(2,$n)){
  $c=strrev(decbin($i));
  $j=0;
  while($j<strlen($c)){
    if($c[$j]==1){
      $k=0;
      while($k<$m+1){
        $p[$i][$k]+=$s[$j][$k];
        ++$k;
      }
    }
    ++$j;
  }
  ++$i;
}
$i=1;
while($i<pow(2,$n)){
  $j=1;
  $flag=1;
  while($j<=$m){
    if($p[$i][$j]<$x){
      --$flag;
      break;
    }
    ++$j;
  }
  if($flag==1){
    $ans=min($ans,$p[$i][0]);
  }
  ++$i;
}
echo ($ans==100000000)?-1:$ans;

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)
#define INF 1e9

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1000000000+7;
const int MAX_N=1000;

int main(){
	int n;
	cin>>n;
	int a[n];
	ll ans=0;
	REP(i,n)cin>>a[i];
	bool flag=false;
	int ki=0;
	int gu=0;
	REP(i,n){
		if(a[i]%2==0)gu++;
		else ki++;
	}
	ans=pow(3,n);
	ans-=pow(2,gu);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string S,R;
    char *C1,*C2;
    int cnt =0;

    cin >> S;
    size_t size = S.length();
    R =  S;
    reverse(S.begin(), S.end());
   // cout << S << endl;
    for (int i=0;i<size;i++) {
   // cout << S.substr(i,1) << endl;
    //cout << R.substr(i,1) << endl;
        if(S.substr(i,1) != R.substr(i,1)){
            cnt++;
        }

    }

    //if(cnt%2 == 0 ){
    //    cout << cnt/2+ 1 << endl;
    //}else{
    //    cout << cnt/2 << endl;
    //}

    cout << cnt /2<< endl;


}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

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

la, lb = [], []

for i in range(N):
    a, b = list(map(int, input().split()))
    la.append(a)
    lb.append(b)

lb = sorted(lb, reverse=True)
ma, c = max(la), 0

for d in lb:
    if d < ma or H <= 0:
        break
    H -= d
    c += 1

if H > 0:
    c += math.ceil(H / ma)

print(c)


Measured memory_bytes: 12164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main()
{
    int a, b, n;
    cin >> n;
    cout << (n < 1200 ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 256
# encoding:utf-8
import math

def main():
	N, M = list(map(int, input().split()))
	
	if abs(N - M) == 0:
		print((math.factorial(N) ** 2 * 2) % (10 ** 9 + 7))
	elif abs(N - M) == 1:
		print((math.factorial(N) * math.factorial(M)) % (10 ** 9 + 7))
	else:
		print(0)

if __name__ == '__main__':
	main()

Measured memory_bytes: 5168
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static class Point{
		int old, x, y;

		public Point(int old, int x, int y) {
			super();
			this.old = old;
			this.x = x;
			this.y = y;
		}
	}
	
	public static int[][] move_dir = new int[][]{{1, 0}, {1, 1}, {0, 1}, {-1, 0}, {-1, -1}, {0, -1}};
	
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		
		final int MAX = 60;
		
		while(true){
			final int t = sc.nextInt();
			final int n = sc.nextInt();
			
			if(t == 0 && n == 0){
				break;
			}
			
			boolean[][] visited = new boolean[MAX + 1 + MAX][MAX + 1 + MAX];
			boolean[][] wall = new boolean[MAX + 1 + MAX][MAX + 1 + MAX];
			
			for(int i = 0; i < n; i++){
				final int x = sc.nextInt();
				final int y = sc.nextInt();
				
				wall[y + MAX][x + MAX] = true;
			}
			
			final int s_x = sc.nextInt();
			final int s_y = sc.nextInt();
			
			Point p = new Point(0 ,s_x + MAX, s_y + MAX);
			LinkedList<Point> queue = new LinkedList<Point>();
			queue.add(p);
			
			int count = 0;
			while(!queue.isEmpty()){
				Point point = queue.poll();
				
				if(point.old > t){
					continue;
				}else if(visited[point.y][point.x]){
					continue;
				}
				
				visited[point.y][point.x] = true;
				count++;
				
				for(int[] move : move_dir){
					final int nx = point.x + move[0];
					final int ny = point.y + move[1];
					
					if(nx < 0 || nx >= (MAX + 1 + MAX) || ny < 0 || ny >= (MAX + 1 + MAX)){
						continue;
					}else if(wall[ny][nx]){
						continue;
					}else if(visited[ny][nx]){
						continue;
					}else{
						queue.add(new Point(point.old + 1, nx, ny));
					}
				}
			}
			
			System.out.println(count);
		}
		
		
	}

}

Measured memory_bytes: 63696
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n>>m;
    char a[n+1][m+1];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)cin>>a[i][j];
    }
    ll dp[n+1][m+1];
    for(i=0;i<=n;i++)dp[i][0]=0;
    for(i=0;i<=m;i++)dp[0][i]=0;
    dp[0][1]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(a[i-1][j-1]=='.')
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
            else dp[i][j]=0;
        }
    }
    cout<<dp[n][m];
}


Measured memory_bytes: 9088
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
g = [[] for _ in range(N)]
rg = [[] for _ in range(N)]
for _ in range(N - 1 + M):
    A, B = (int(x) - 1 for x in input().split())
    g[A].append(B)
    rg[B].append(A)


def dfs(s, ts, used):
    used[s] = True
    for t in g[s]:
        if not used[t]:
            dfs(t, ts, used)
    ts.append(s)


def tsort():
    ts = []
    used = [False] * N
    for i in range(N):
        dfs(i, ts, used)
    return ts[::-1]


ts = tsort()
mp = {x: i for i, x in enumerate(ts)}

ans = [None] * N
for t in tsort():
    ans[t] = ts[max(mp[s] for s in rg[t])] + 1 if rg[t] else 0

print(*ans, sep='\n')


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

auto pow3 = [](int64_t a){return a*a*a;};
int main()
{
  int n,k;
  cin>>n>>k;
  int64_t ans=pow3(n/k);
  if(k%2!=0){
    cout<<ans;
    return 0;
  }
  ans+=pow3(n/(k/2)-n/k);
  
  cout<<ans;
}

Measured memory_bytes: 256
package main

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

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

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

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

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

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

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

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

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

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

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

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

type xxx struct {
	x int
}

type sortArray []xxx

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

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

func main() {
	n := readInt()
	A := make([]string, n)
	m := make(map[string]int, n)
	for i := range A {
		s := readString()
		p := readInt()
		A[i] = s + strconv.Itoa(p-999)
		m[A[i]] = i + 1
	}

	sort.Sort(sort.StringSlice(A))
	for _, a := range A {
		fmt.Println(m[a])
	}
}


Measured memory_bytes: 640
<?php
$M = trim(fgets(STDIN));
//list($d,$c) =  explode(" ",trim(fgets(STDIN)));

switch($M) {
case 'MON':
  $ret = 6;
  break;
case 'TUE':
  $ret = 5;
  break;
case 'WED':
  $ret = 4;
  break;
case 'THU':
  $ret = 3;
  break;
case 'FRI':
  $ret = 2;
  break;
case 'SAT':
  $ret = 1;
  break;
case 'SUN':
  $ret = 7;
  break;
}
printf("%d\n",$ret);


Measured memory_bytes: 4856
def main():
    A = int(raw_input())
    B = int(raw_input())
    C = int(raw_input())
    X = int(raw_input())

    count = 0

    for i in range(A+1):
        if i*500 > X:
            continue
        for j in range(B+1):
            if i*500 + j*100 > X:
                continue
            
            for k in range(C+1):
                if i*500 + j*100 + k*50 == X:
                    count += 1

                if i*500 + j*100 + k*50 > X:
                    break

    print count

main()


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

int main(){
    ll n;cin>>n;
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

string maxstrAsint(string a,string b){

    if(a.size() == b.size()){
        
        if(a >= b)return a;
        else return b;
    
    }else{
        if(a.size() > b.size())return a;
        else return b;
    }
}

int main(){

    bool flag=false;

    ll ans=0,sum=0;

    int n,m;
    cin >>n>>m;

    vector<int> mch = {INF,2,5,5,4,5,6,3,7,6};
    vector<int> canmake(m);

    vector<string> dp(n+1,"");


    for (int i = 0; i < m; i++){
        cin >> canmake[i];
    }

    for (int i = 0; i <= n; i++){
        for (int j = 0; j < m; j++){

            if(i >= mch[canmake[j]]){

                if(i == mch[canmake[j]] || dp[i-mch[canmake[j]]]!=""){
                    string app = to_string(canmake[j]);
                    dp[i] = maxstrAsint(dp[i],dp[i-mch[canmake[j]]]+app);
                }
            }

        }
        //cout << dp[i] << endl;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << dp[n] << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 41600
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y){
    ll ans=1;
    REP(i,y){
        ans*=x;
    }
    return ans;
}

int main()
{
    int N, P; cin >> N >> P;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }
    ll ans=0;
    int ki=0, gu=0;

    REP(i,N){
        if(A[i]%2==0)   gu++;
        else    ki++;
    }

    if(gu==N){
        if(P==0){
            cout << llpow(2,N) << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << llpow(2,N-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if( (i%2==0 && s[i]=='L')|| (i%2 && s[i]=='R') ){
			cout <<"No"<<"\n";
			return 0;
		}
	}
	cout <<"Yes"<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

#include <cmath>

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point {
public:
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a*x, a*y); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

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

typedef Point Vector;

struct Segment {
	Point p1, p2;
};

typedef Segment Line;

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};


double norm(Vector a) {
	return a.norm();
}

double abs(Vector a) {
	return a.abs();
}

double dot(Vector a, Vector b) {
	return a.x*b.x + a.y*b.y;
}

double cross(Vector a, Vector b) {
	return a.x*b.y - a.y*b.x;
}

bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
	return isOrthogonal(s1.p1, s1.p2, s2.p1, s2.p2);
}

bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
	return isParallel(s1.p1, s1.p2, s2.p1, s2.p2);
}

Point project(Segment s, Point p) {
	double alpha = dot(p - s.p2, s.p1 - s.p2) / (s.p1 - s.p2).norm();
	return s.p2 + (s.p1 - s.p2)*alpha;
}

Point reflect(Segment s, Point p) {
	return project(s, p)*2.0 - p;
}

int main() {
	Line l;
	cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
	int q;
	cin >> q;
	Point p;
	for (int i = 0; i < q; i++) {
		cin >> p.x >> p.y;
		Point x = reflect(l, p);
		cout << fixed << setprecision(15);
		cout << x.x << " " << x.y << endl;
	}

	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int sp;
string data;

int calc();
int num();
int expr();
int factor();

signed main()
{
    cin >> data;
    Int(ans);
    sp = 0;
    int a = expr();
    sp = 0;
    int b = calc();
    if (a == ans && b == ans) {
        cout << "U" << endl;
    } else if (a == ans) {
        cout << "M" << endl;
    } else if (b == ans) {
        cout << "L" << endl;
    } else {
        cout << "I" << endl;
    }
    return 0;
}

int calc()
{
    int ret = num();
    while (sp < data.length() ) {
        if ( data[sp] == '*' ) {
            sp++;
            ret *= num();
        } else if ( data[sp] == '+' ) {
            sp++;
            ret += num();
        } else {
            break;
        }
    }
    return ret;
}

int expr()
{
    int ret = factor();
    while ( sp < data.length() ) {
        if (data[sp] == '+') {
            sp++;
            ret += factor();
        } else {
            break;
        }
    }
    return ret;
}

int factor()
{
    int ret = num();
    while ( sp < data.length() ) {
        if (data[sp] == '*' ) {
            sp++;
            ret *= num();
        } else {
            break;
        }
    }
    return ret;
}

int num()
{
    int ret = 0;
    while ( sp < data.length() ) {
        if ( '0' <= data[sp] && data[sp] <= '9' ) {
            ret *= 10;
            ret += data[sp++] - '0';
        } else {
            break;
        }
    }
    return ret;
}

Measured memory_bytes: 3284
import math
N, H = map(int, input().split())
a = []
b = []
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

throw = 0
throw_count = 0
max_a = max(a)
b.sort(reverse=1)
for i in b:
    if i < max_a:
        break

    throw += i
    throw_count += 1
    if throw >= H:
        print(throw_count)
        exit()

print(math.ceil((H - throw)/max_a) + throw_count)

Measured memory_bytes: 11312
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static int queryCount=0;
    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        String s=scanner.next();
        String[] strings=s.split("");
        System.out.println(Arrays.stream(strings).mapToInt(ss->Integer.parseInt(ss)).sum());
    }
}


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,0,n){
        cin>>c[i];
        rep(j,0,m){
            cin>>a[i][j];
        }
    }
    ll ans=INF;
    for(int bit=0;bit<(1<<n);bit++){
        ll val=0;
        vector<ll> sum(m);
        // bit全探索 各理解度がx以上、最小の金額が答え。
        for(int i=0;i<n;i++){
            if((bit>>i)&1){
                val+=c[i];
                rep(j,0,m){
                    sum[j]+=a[i][j];
                }
            }
        }
        bool can=true;
        rep(i,0,m){
            if(sum[i]<x){can=false;break;}
        }
        if(can)ans=min(ans,val);
    }
    if(ans!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

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

#define FOR(VAR,ST,END) for(int VAR=ST; VAR<END; ++VAR)
#define FORI(VAR,ST,END) for(int VAR=ST; VAR<=END; ++VAR)
#define ROF(VAR,ST,END) for(int VAR=ST; VAR>END; --VAR)
#define ROFI(VAR,ST,END) for(int VAR=ST; VAR>=END; --VAR)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define MAXI(a,b) (a=(a>b?a:b))
#define MINI(a,b) (a=(a<b?a:b))
#define MINI_NZ(a,b) {if(a==0) a = b; else a = a<b?a:b;}
#define SWAP_IF(type,x,y,cond) if(cond) {type tmp=x; x=y; y=tmp;}
#define SWAP(type,x,y) {type tmp=x; x=y; y=tmp;}
#define INF 0x3f3f3f3f

#define MAX_N 100
#define MAX_TURNING 20

using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << n / 3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    if (64 < n  && n < 91){
        cout << 1 << endl;
    }else if(96 < n  && n < 123){
        cout << 2 << endl;
    } else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3104
X,N = map(int,input().split())
p = list(map(int,input().split()))
a,b = [],[]
cnt = 0
for i in range(0,100):
    if X + cnt not in p:
        a.append(X + cnt)
    if X - cnt not in p:
        b.append(X - cnt)
    cnt += 1
A = a[0]-X
B = X-b[0]
if A < B:
    print(a[0])
else:
    print(b[0])

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline
T fact(T n){
  T res=1;
  for(T i=1;i<=n;i++)res*=i;
  return res;
}

inline void solve(void){
  int N;
  in(N);
  vector<pair<int,pair<double,double>>>p;
  rep(i,N){
    double x,y;
    in(x,y);
    p.pb(mp(i,mp(x,y)));
  }
  double sum=0;
  do{
    double tmp=0;
    rep(i,N-1){
      tmp+=sqrt(pow(p[i].sd.ft-p[i+1].sd.ft,2)+pow(p[i].sd.sd-p[i+1].sd.sd,2));
    }
    sum+=tmp;
  }while(next_permutation(all(p)));
  out(sum/fact(N));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x;
	cin >> x;
	int sm = 0;
	int Now = 1;
	while (1){
		sm += Now;
		if (sm >= x) return cout << Now, 0;
		//else if(sm > x) return cout << Now + 1, 0;
		Now++;
	}












	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
int h,w;
bool inside(int i,int j)
{
    return i>=0&&i<h&&j>=0&&j<w;
}
vector<int> dx={1,-1,0,0},dy={0,0,1,-1};
int main()
{
	scanf("%i %i",&h,&w);
	vector<string> board(h);
	for(int i=0;i<h;i++)
        cin >> board[i];
    long long cnt=0;
    vector<pair<int,int> > graf[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            for(int k=0;k<4;k++)
            {
                int xx=i+dx[k];
                int yy=j+dy[k];
                if(!inside(xx,yy))
                    continue;
                if(board[i][j]!=board[xx][yy])
                {
                    graf[i][j].pb({xx,yy});
                }
            }
        }
    }
    vector<vector<int> > visited(h,vector<int>(w));
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(visited[i][j])
                continue;
            queue<pair<int,int> > q;
            q.push({i,j});
            visited[i][j]=1;
            long long c1=0,c2=0;
            while(q.size())
            {
                int x=q.front().f;
                int y=q.front().s;
                if(board[x][y]=='#')
                    c1++;
                else
                    c2++;
                q.pop();
                for(auto p:graf[x][y])
                {
                    int xx=p.f;
                    int yy=p.s;
                    if(visited[xx][yy]==0)
                    {
                        visited[xx][yy]=1;
                        q.push({xx,yy});
                    }
                }
            }
            cnt+=c1*c2;
        }
    }
    printf("%lld\n",cnt);
    return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>

double dp[303][303][303];
int count[4];

double rec(int i, int j, int k, int n){
    if(!i && !j && !k) return 0.0;
    if(dp[i][j][k]) return dp[i][j][k];
    dp[i][j][k] = n;
    if(i > 0) dp[i][j][k] += i * rec(i-1, j, k, n);
    if(j > 0) dp[i][j][k] += j * rec(i+1, j-1, k, n);
    if(k > 0) dp[i][j][k] += k * rec(i, j+1, k-1, n);
    return dp[i][j][k] /= (double)(i + j + k);
}

int main(){
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        count[a]++;
    }
    std::cout << std::fixed << std::setprecision(10) << rec(count[1], count[2], count[3], n) << std::endl;
}


Measured memory_bytes: 217344
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n,m,i;
  	cin>>n>>m;
  	int a[m],sum = 0;
  	for(i=0;i<m;++i){
      	cin>>a[i];
      	sum += a[i];
    }
  	if(sum > n)
      	cout<<"-1\n";
  	else
      	cout<<n-sum<<"\n";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - h * W - H * w + h * w << endl;
    return 0;
}


Measured memory_bytes: 256
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int64_t> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }

    vector<vector<int64_t>> dp(n, vector<int64_t>(n, 0));

    for (int i = 0; i < n; i++)
    {
        dp[i][i] = n % 2 == 0 ? -vs[i] : vs[i];
    }

    for (int w = 1; w < n; w++)
    {
        for (int l = 0; l < n - w; l++)
        {
            const int r = l + w;
            if ((n - 1 - w) % 2 == 0)
            {
                dp[l][r] = max(dp[l + 1][r] + vs[l], dp[l][r - 1] + vs[r]);
            }
            else
            {
                dp[l][r] = min(dp[l + 1][r] - vs[l], dp[l][r - 1] - vs[r]);
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define int long long

int H, W, dp[1005][1005];
const int M = 1e9 + 7;
char A[1005][1005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> H >> W;
	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++)
			cin >> A[i][j];
	dp[H][W] = 1;
	for (int i = H; i >= 1; i--)
		for (int j = W; j >= 1; j--)
			if (A[i][j] != '#' && (i != H || j != W))
				dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % M; 
	cout << dp[1][1] << '\n';
}


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

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

	int k, display_total, inner_rating; cin >> k >> display_total;
	if (k >= 10)
	{
		cout << display_total << endl;
	}
	else
	{
		cout << display_total + (100 * (10 - k));
	}
	return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
 
 #define int long long
 #define pa pair<int,int>
  #define  mp make_pair
  #define  pb push_back
 using namespace std;
int beki(int wa,int rr,int warukazu){
	if(rr==0) return 1%warukazu;
	if(rr==1) return wa%warukazu;
	wa%=warukazu;
	if(rr%2==1) return (beki(wa,rr-1,warukazu)*wa)%warukazu;
	int zx=beki(wa,rr/2,warukazu);
	return (zx*zx)%warukazu;
}
int D[3000000];
const int MOD=998244353;
void fourie(int N,int d,vector<int> &vec ){// 1<<d == N
	// Uは順方向ではexp(2pi*I/N)逆だとexp(-2pi*I/N)
	if(N==1){
		return;
	}
	int gyaku=0;
	for(int i=1;i<N;i++){
		int e=1<<(d-1);
		while(gyaku&e){
			gyaku^=e;
			e>>=1;
		}
		gyaku^=e;
		if(i<gyaku)swap(vec[i],vec[gyaku]);	
	}
	for(int c=0;c<d;c++){
		int f=1<<c;
		for(int i=0;i<N;i+=(f<<1)){
			for(int j=i;j<i+f;j++){
				int A1=(vec[j]+vec[j+f]*D[(j-i)<<(d-c-1)])%MOD;
				int A2=(vec[j]-(vec[j+f]*D[(j-i)<<(d-c-1)]%MOD)+MOD)%MOD;
				vec[j]=A1;
				vec[j+f]=A2;
			}
		}
	}
 
	return;
}
 
vector<int> NTT(vector<int> input1,vector<int> input2){//MOD=998244353;
int N=1;
	int d=0;
	int size1=input1.size(),size2=input2.size();
	while(N<size1+size2){
		N*=2;
		d++;
	}
	assert(N==(1<<d));
	while(input1.size()<N)input1.pb(0);
	while(input2.size()<N)input2.pb(0);
	for(auto v:input1){
		if(v<0) v=MOD-((-v)%MOD);
		if(v>=MOD) v%=MOD;
	}
	for(auto v:input2){
		if(v<0) v=MOD-((-v)%MOD);
		if(v>=MOD) v%=MOD;
	}
	// (3^119)^(2^23)=1 mod 998244353
	int g=beki(3,119,MOD);
	for(int i=0;i<23-d;i++)g=(g*g)%MOD;
	
	//cout<<"   "<<beki(g,N,998244353)<<endl;
	
	D[0]=1;
	for(int i=1;i<N;i++){
		D[i]=D[i-1]*g%MOD;
	}
	fourie(N,d,input1);
	fourie(N,d,input2);
	vector<int> ANS;
	
	for(int i=0;i<N;i++)input1[i]=input1[i]*input2[i]%MOD;
	for(int i=1;i<N/2;i++)swap(D[i],D[N-i]);
	
	fourie(N,d,input1);
	int ninv=beki(N,MOD-2,MOD);
	for(int i=0;i<N;i++)input1[i]=input1[i]*ninv%MOD;
	
	for(int i=0;i<size1+size2-1;i++){
		ANS.pb(input1[i]);
	}
	return ANS;
}
 
 signed main(){
 	
 
    cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,k,l;
 	cin>>n>>m>>k>>l;
 	vector<int> V(m*m,0),W(m*m,0);
  	for(int i=0;i<n;i++){
 		string s;
 		cin>>s;
 		for(int j=0;j<n;j++){
 			if(s[j]=='X')V[(i)*m+j]=1;
 		}
 	}
 	int x=0,y=0;
 	string S;
 	cin>>S;
 	for(auto c:S){
 		if(c=='R')y++;
 		if(c=='L')y--;
 		if(c=='U')x--;
 		if(c=='D')x++;
 		W[x*m+y]+=1;
 	}
 	vector<int> ans=NTT(V,W);
 	int ans1=0;
 	for(auto c:ans)if(c>=k)ans1++;
 	cout<<ans1<<endl;
return 0;

 }


Measured memory_bytes: 27260
#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)

char S[8][9];

bool check(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
	if (S[y1][x1]=='1' && S[y2][x2]=='1' &&S[y3][x3]=='1' &&S[y4][x4]=='1'){
		return true;
	}
	return false;
}

int main(){
	while (scanf("%s",S[0])!=EOF){
		FOR(i,1,8){
			scanf("%s",S[i]);
		}
		REP(i,7){
			REP(j,7){
				if (check(i,j,i+1,j,i,j+1,i+1,j+1)){
					printf("A\n");
				}
			}
		}
		REP(i,8){
			REP(j,5){
				if (check(i,j,i,j+1,i,j+2,i,j+3)) printf("B\n");
			}
		}
		REP(i,5) REP(j,8) if (check(i,j,i+1,j,i+2,j,i+3,j)) printf("C\n");
		REP(i,7) REP(j,6) if (check(i+1,j,i,j+1,i+1,j+1,i,j+2)) printf("D\n");
		REP(i,6) REP(j,7) if (check(i,j,i+1,j,i+1,j+1,i+2,j+1)) printf("E\n");
		REP(i,7) REP(j,6) if (check(i,j,i,j+1,i+1,j+1,i+1,j+2)) printf("F\n");
		REP(i,6) REP(j,7) if (check(i+1,j,i+2,j,i,j+1,i+1,j+1)) printf("G\n");
	}
	return 0;
}

Measured memory_bytes: 1112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);

		tmpArray = br.readLine().split(" ");

		PriorityQueue<Integer> pq = new PriorityQueue<Integer>(new Comparator<Integer>() {

			@Override
			public int compare(Integer i1, Integer i2) {
				// TODO 自動生成されたメソッド・スタブ
				return i2 - i1;
			}
		});

		for(int i = 0; i < n; i++){
			int tmp = Integer.parseInt(tmpArray[i]);
			pq.add(tmp);
		}
		for(int i = 0; i < m; i++){
			int tmp = pq.remove();
			tmp /= 2;
			pq.add(tmp);
		}

		long result = 0;
		for(int i = 0; i < n; i++){
			int tmp = pq.remove();
			result += tmp;
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 49692
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int D,X;
    cin>>D>>X;
    int choco=X;
    int A;
    for(int i=0;i<N;i++){
        cin>>A;
        int j=0;
        while(1+j*A<=D){
            choco+=1;
            j++;
        }
    }
    cout<<choco<<endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    while (true) {
        val a =scanner.nextInt()
        val op =scanner.next()
        val b =scanner.nextInt()
        if (op == "?") break
        val answer = when(op) {
            "+" -> a + b
            "-" -> a - b
            "*" -> a * b
            "/" -> a / b
            else -> 0
        }
        println(answer)
    }
}



Measured memory_bytes: 25540
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s;
int n,k;
int main(){
    cin>>n>>k;
    cin>>s;
    vector<pint> v;
    int cur=0;
    while(cur<n){
        int c1=0,c2=0;
        while(cur<n&&s[cur]=='1') ++cur,++c1;
        while(cur<n&&s[cur]=='0') ++cur,++c2;
        v.pb(c1,c2);
    }
    int ans=0,cnt=0;
    rep(i,k)if(i<v.size()){
        cnt+=v[i].first+v[i].second;
    }
    if(k<v.size()) cnt+=v[k].first;
    ans=max(cnt,ans);
    FOR(i,k,v.size()){
        cnt-=v[i-k].first+v[i-k].second;
        cnt+=v[i].second+(i+1<v.size()?v[i+1].first:0);
        ans=max(cnt,ans);
    }
    cout<<ans<<endl;
    return 0;
}


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


using ll = long long int;

using namespace std;

int i, j, N, K, R, S, P;

int get_score(char s)
{
    int ans;
    if (s == 's')
        ans = R;
    if (s == 'r')
        ans = P;
    if (s == 'p')
        ans = S;
    
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    
    cin >> N >> K >> R >> S >> P;
    
    string t;
    
    cin >> t;
    
    //string me(n, 'a');
    
    bool can[K] = {};
    
    ll ans = 0;
    
    for(i = 0; i < N; ++i)
    {
        if (i < K)
        {
            ans += get_score(t[i]);
        }
        else
        {
            if (t[i - K] == t[i])
            {
                if (can[i % K])
                {
                    ans += get_score(t[i]);
                }
                can[i % K] = (1 - can[i % K]);
            }
            else
            {
                can[i % K] = 0;
                ans += get_score(t[i]);
            }
        }
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N;
    cin >> N;
    vector<string> syouhin(N);
    map<string,ll> mpa;

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

    for(ll i = 0;i < N;i++){
        mpa[syouhin[i]]++;
    }

    cout << mpa.size() << endl;



}

Measured memory_bytes: 25016
#include <bits//stdc++.h>
using namespace std;
int main(void){
  int n,ans=0;
  cin >> n;
  int l,r;
  for(int i=0;i<n;i++){
      cin >> l >> r;
      ans+=r-l+1;
  }
  cout << ans << endl;
    return 0;
}


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


int main(){
    int P[100000], Y[100000];
    vector<int> V[100001];
    int N,M;
    cin >> N >> M;

    for(int i=0; i<M; i++){
        cin >> P[i] >> Y[i];
        V[P[i]].push_back(Y[i]);
    }

    for(int i=1; i<N+1; i++){
        sort(V[i].begin(), V[i].end());
    }

    for(int i=0; i<M; i++){
        auto it=lower_bound(V[P[i]].begin(), V[P[i]].end(), Y[i]);
        int rank=it-V[P[i]].begin()+1;
        printf("%06d%06d\n", P[i], rank);
    }

    return 0;
}

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

int main(void) {
    double a, b, x;
    cin >> a >> b >> x;
    double angle;
    if (x > a * a * b / 2) {
        angle = atan2(2.0 * (a * a * b - x), (a * a * a));
        angle *= 180;
        angle /= M_PI;
    } else {
        angle = atan2(2 * x, a * b * b);
        angle *= 180;
        angle /= M_PI;
        angle = 90 - angle;
    }
    printf("%.10f\n", angle);

    return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)


int main()
{
    int n;
    string s;
    cin>>n>>s;
    string st="";
    char c=s[0];
    st+=c;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==c)
            continue;
        else
        {
            st+=s[i];
            c=s[i];
        }
    }
//    cout<<st<<endl;
    cout<<st.size();


}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,m,father[N],sum[N];
int Findfather(int x){
    return father[x]==x?x:father[x]=Findfather(father[x]);
}

void Union(int x,int y){
    x=Findfather(x),y=Findfather(y);
    if(x!=y) father[y]=x,sum[x]+=sum[y];
}

void init(){//注意init的位置在输入n之后!!!
    for(int i=0;i<=n;i++)
        father[i]=i,sum[i]=1;
}

int main(){
    cin>>n>>m;
    init();
    while(m--){
        int u,v;
        cin>>u>>v;
        Union(u,v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(Findfather(i)==i) ans=max(ans,sum[i]);
    cout<<ans;
}




Measured memory_bytes: 5500
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

ll mod=1e9+7;

ll gcd(ll n,ll m){
  if(m==0) return n;
  else return gcd(m,n%m);
}

ll lcm(ll n,ll m){
  return n/gcd(n,m)*m;
}

string bit(ll n){
  string ans="";
  while(n>0){
    char c=n%2+'0';
    ans=c+ans;
    n/=2;
  }
  return ans;
}

ll order(ll n,ll p){
  ll ans=0;
  while(n%p==0){
    ans++;
    n/=p;
  }
  return ans;
}

ll modinv(ll a){
  ll b=mod,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=mod;
  if(u<0) u+=mod;
  return u;
}
 
ll fac[300010];
 
void modfac(){
  fac[0]=1;
  for(ll i=1;i<300010;i++){
    fac[i]=(fac[i-1]*i)%mod;
  }
}

ll modcomb(ll n,ll k){
  return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

// 仮ライブラリ（？）

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  cout << c/a*b << endl;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

a_sub = []
for i in range(n):
    if i == n - 1:
        subs = a[0] + k - a[n-1]
    else:
        subs = a[i+1] - a[i]
    a_sub.append(subs)

print(k - max(a_sub))

Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
	int N, L[11];
	int max = 0, max_index = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		if (L[i] > max) {
			max = L[i];
			max_index = i;
		}
	}

	int sum = 0;
	for (int j = 0; j < max_index; j++) {
		sum += L[j];
	}
	for (int j = max_index + 1; j < N; j++) {
		sum += L[j];
	}
	if (L[max_index] < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int max(int a, int b, int c){
	int v[3] = {a, b, c};
	sort(v, v + 3);
	return v[2];
}

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", max(a + b, a - b, a*b));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const bool DEBUG = true;
#define coutd if(DEBUG) cout 
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	cout << (n*(n-1))/2 << endl;
}


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

using namespace std;

int calc(int n)
{
    const int max = static_cast<int>(round(sqrt(n - 2) - 1));

    vector<tuple<int, int, int>> ans;
    for(int x = 1; x <= max; ++x)
    {
        for(int y = 1; y <= x; ++y)
        {
            for (int z = 1; z <= y; ++z)
            {
                if( x * x + y * y + z * z + x * y + y * z + z * x == n)
                {
                    ans.emplace_back(x, y, z);
                }
            }
        }
    }

    int count = 0;
    for(const auto& elem: ans)
    {
        int x, y, z;
        tie(x, y, z) = elem;

        int dupl = 0;
        if(x == y)
        {
            ++dupl;
        }
        if(y == z)
        {
            ++dupl;
        }
        if(z == x)
        {
            ++dupl;
        }
        switch (dupl)
        {
        case 0:
            count += 6;
            break;
        case 1:
            count += 3;
            break;
        default:
            count += 1;
            break;
        }
    }
    return (count);
}

int main(void)
{
    int N;
    cin >> N;

    cout << 0 << endl;
    for(int i = 2; i <= N; ++i)
    {
        cout << calc(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 3684
def solve(n, a):
    """
    References
    ----------
    [1]. 足跡-sokuseki-, CODE FESTIVAL 2016 Grand Final C - Cheating Nim, http://wk1080id.hatenablog.com/entry/2018/08/17/234023
    [2]. iroiro, CODE FESTIVAL 2016 Grand Final C - Cheating Nim, http://xxxasdfghjk999.hatenablog.jp/entry/2018/11/01/235259
    [3]. Yang33, 競プロにおけるNim、Grundy数とNimK, http://yang33-kassa.hatenablog.com/entry/2017/12/21/202812
    """
    x = 0
    for i in range(n):
        x ^= a[i]
    b = [a[i] ^ (a[i] - 1) for i in range(n)]
    mapping = {2**k-1: 0 for k in range(31)}
    for y in b:
        mapping[y] += 1
    ans = 0
    for k in range(30, 0, -1):
        y = 2**k - 1
        z = 2**(k-1)
        if (x & z) > 0 and (mapping[y] > 0):
            ans += 1
            mapping[y] -= 1
            x ^= y
    return ans if x == 0 else -1

n = int(input())
a = [int(input()) for i in range(n)]
print(solve(n, a))



Measured memory_bytes: 11064