akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  int M=0;
  cin >> N;
  if (N%2==1){
    for (int X=N; X>0; X-=2){
        int Z=1;
      for (Y=X/2; Y>0; Y--){
        if (X%Y==0){
          Z++;
        }
      }
      if (Z==8){
        M++;
      }
    }
  }
  else if (N%2==0){
    N-=1;
    for (int X=N; X>0; X-=2){
        int Z=1;
      for (Y=X/2; Y>0; Y--){
        if (X%Y==0){
          Z++;
        }
      }
      if (Z==8){
        M++;
      }
    }
  }
  cout << M << endl;
}

Measured memory_bytes: 256
S = input()

result = 0
# 入力例1なら3文字目まで
for i in range(len(S) // 2):
  # sの1(2番目)がsの最後尾と一緒ならカウント
  if S[i] != S[-(i + 1)]:
    result += 1
print(result)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)



ll K,X,Y;
ll Sn;
ll dp[101010][15];
ll i,j,k;
vector<pll> anss;

ll Abs(ll a){
    return a < 0 ? -a : a;
}
pll st(){
    pll xy = {0, 0};
    while(X!=xy.first&&Abs(X-xy.first)+Abs(Y)>=K*2){
        if(Abs(xy.first-X)<K){
            ll a = K-Abs(xy.first - X);
            xy.second += 0 < Y ? a : -a;
            xy.first = X;
        }else{
            xy.first += 0 < X ? K : -K;
        }
        anss.push_back(xy);
    }
    while(Abs(Y-xy.second)>=K*2){
        xy.second += 0 < Y ? K : -K;
        anss.push_back(xy);
    }
    return xy;
}
void solve2(ll x,ll y,ll rx,ll ry){
    ll a = Abs(rx) + Abs(ry);
    ll b = (K * 2 - a) / 2;
    if(abs(rx)>abs(ry)){
        anss.push_back({(X < 0 ? b - K : K - b) + x, (Y < 0 ? b : -b) + y});
    }else{
        anss.push_back({(X < 0 ? b : -b) + x, (Y < 0 ? b - K : K - b) + y});
    }
    anss.push_back({X, Y});
}

int main(){
    scanf("%lld%lld%lld", &K, &X, &Y);
    if(K%2==0&&((X+Y)%2)){
        printf("-1");
        return 0;
    }
    auto xy=st();
    //printf("%lld,%lld\n", xy.first, xy.second);
    ll a = Abs(X - xy.first) + Abs(Y - xy.second);
    if(a%2){
        if(a<K){
            xy.first = (X < 0 ? K : -K)+xy.first;
        }else{
            ll b = Abs(X - xy.first);
            if(b<K){
                ll c = K - b;
                xy.second = (Y < 0 ? -c : c) + xy.second;
                xy.first = X;
            }else{
                xy.first = (X < 0 ? -K : K)+xy.first;
            }
        }
        anss.push_back(xy);
    }else if(a==K){
        anss.push_back({X, Y});
    }
    if(a!=K)
        solve2(xy.first, xy.second, Abs(X - xy.first), Abs(Y - xy.second));
    printf("%d\n",anss.size());
    fornum(i,0,anss.size()){
        printf("%lld %lld\n", anss[i].first, anss[i].second);
    }

    return 0;
}

Measured memory_bytes: 5484
#include <cstdio>

int main(){
    int n, a[100];
    scanf("%d", &n);
    for (int i = 0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i<n; i++){
        printf("%d", a[n-1-i]);
        if(i<n-1){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const double PI=acos(-1.0);
int main(){
	double r;
	cin>>r;
	printf("%.6lf\n",2*PI*r);
	
	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll k, n;
  cin >> k >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll maxDist = 0;
  sort(all(a));
  for (int i = 1; i < n; i++) {
    maxDist = max(a[i] - a[i - 1], maxDist);
  }
  maxDist = max(a[0] + k - a[a.size() - 1], maxDist);
  cout << k - maxDist << endl;
  return 0;
}

Measured memory_bytes: 1792
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))
 
print(abs(area_polygon(p)))

Measured memory_bytes: 7400
import sys
input = sys.stdin.readline
n,p = [int(i) for i in input().split()]
s = input()
ans = 0

import math
def nCr(n, r):
  if n < r:
    return 0
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
    exit()

else:
  chk = [0]*p
  chk[0] = 1
  m = 0
  for i in range(n)[::-1]:
    m = (int(s[i])*pow(10,n-1-i,p)+m)%p
    chk[m] += 1
  for i in chk:
    ans += nCr(i,2)
  print(ans)


Measured memory_bytes: 58972
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, A, B;
  cin >> N >> A >> B;
  if (A > B) {
    print("0");
  } else if (A == B) {
    print("1");
  } else {
    if (N == 1) {
      print("0");
    } else {
      print((B - A) * (N - 2) + 1);
    }
  }
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , p , a;

int main(){
    cin >> n >> p;
    bool odd = false;
    rep(i,0,n) {
        cin >> a;
        odd |= a & 1;
    }
    if(odd) cout << (1ll << (n - 1)) << endl;
    else cout << (p & 1 ? 0 : (1ll << n)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define MOD int(1e9) +7


llong kaijou(llong a){
    llong i=1;
    llong ans=1;
    FOR(i,1,a+1){
        ans*=i;
        ans%=MOD;
    }
    return ans;
}

int main(){
    llong n,m;
    cin >> n >> m;
    if( abs(n-m) >= 2){
        cout << 0 << endl;
        return 0;
    }
   
   llong ans=0;
   ans = kaijou(n) * kaijou(m);
   if(n==m) ans*=2;
   ans%=MOD;
   cout << ans << endl;

}




Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() { XXX() }

func XXX() {
	stdin.Scan()
	w := []string{"Sunny", "Cloudy", "Rainy"}
	i := map[string]int{"Sunny": 1, "Cloudy": 2, "Rainy": 0}
	s := stdin.Text()
	fmt.Println(w[i[s]])

}

Measured memory_bytes: 640
#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
    int ans[100];
    int n,k;
    cin>>n>>k;
    for(int i = 0; i<k; i++)
    {
        int a;
        cin>>a;
        ans[a]= 1;
    }
    for(int j = n; ; j++)
    {
        int u = j;
        int bns[100]={0};
        int num =0;
        while(u)
        {
            bns[u%10] = 1;
            u/=10;
        }
        int temp =0;
        for(int i = 0; i<=9; i++)
        {
            if(bns[i]==ans[i]&&ans[i]==1)
                temp = 1;
        }
        if(temp==0)
        {
            cout<<j<<endl;
           return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 1e5+5;
const ll modd = 1000000007;
int head[N],to[N<<1],nex[N<<1],cnt;
int fat[N];
void addedge(int u,int v){
    to[++cnt] = v;
    nex[cnt] = head[u];
    head[u] = cnt;
}
ll ans = 1;
int n,k;
void dfs(int x,int fa){
    int timm = -1;
    for(int i=head[x];i;i=nex[i]){
        int v= to[i];
        if(v==fa) continue;
        ++timm;
        //if(timm>2) timm=2;
        ans = (ans * ((ll)k-(fat[v]!=0)-(fat[fat[v]]!=0)-timm) )%modd;
        //cout<<x<<" "<<"time:"<<timm<<endl;
        //cout<<"sub:"<<(k-(fat[v]!=0)-(fat[fat[v]]!=0)-timm)<<endl;
        //cout<<ans<<endl;
        
        dfs(v,x);
    }
}
void dfs1(int x,int fa){
    for(int i=head[x];i;i=nex[i]){
        int v= to[i];
        if(v==fa) continue;
        fat[v] = x;
        dfs1(v,x);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;
    rep(i,1,n-1){
        int a,b;cin>>a>>b;
        addedge(a,b);addedge(b,a);
    }

    dfs1(1,0);
    // rep(i,1,n){
    //     cout<<"fa"<<i<<" :"<<fat[i]<<endl;
    // }
    ans = k;
    dfs(1,0);
    
    cout<<ans;

}

Measured memory_bytes: 11844
inputCount = int(input())

for _ in range(inputCount):

    inputContent = input()
    trainOrder = [item for item in inputContent if str.isalpha(item)]
    directOrder = [item for item in inputContent if item == "<" or item == ">"]

    trainList = []
    trainList.append(trainOrder[0])
    listIndex = 1
    trainLength = 1

    for train, direct in zip(trainOrder[1:], directOrder):

        if listIndex == 1 and direct == "<":
            trainList.insert(0, train)
            trainLength += 1
        elif listIndex == trainLength and direct == ">":
            trainList.append(train)
            listIndex += 1
            trainLength += 1

        elif direct == "<":
            listIndex -= 1
        else:
            listIndex += 1

    output = "".join(trainList)
    print(output)



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

int main() {
  int N,M;
  string s;
  cin>>N;
  vector<int> A(4);
  for(int i=0;i<N;i++){
    cin>>s;
    if(s=="AC")A[0]++;
    else if(s=="WA")A[1]++;
    else if(s=="TLE")A[2]++;
    else if(s=="RE")A[3]++;
  }
  cout<<"AC x "<<A[0]<<endl;
  cout<<"WA x "<<A[1]<<endl;
  cout<<"TLE x "<<A[2]<<endl;
  cout<<"RE x "<<A[3]<<endl;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize
    }
    println!("{}", 6 - a - b);
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

			int N = scan.nextInt();
			int W = scan.nextInt();
			int[]w = new int[N+1];
			int[]v = new int[N+1];
			for(int i = 1;i<=N;i++) {
				w[i] = scan.nextInt();
				v[i] = scan.nextInt();
			}

			long[][]dp = new long[N+1][W+1];


			for(int z = 0;z<=W;z++) {
				for(int i = 1;i<=N;i++) {
					if(z-w[i]>=0) {
						dp[i][z] = Math.max(dp[i-1][z-w[i]]+v[i], dp[i-1][z]);
					}else {
						dp[i][z] = dp[i-1][z];
				}
			}
			}

			/*
			for(int i = 0;i<=W;i++) {
				for(int j = 0;j<N;j++) {
					System.out.print(dp[j][i]+" ");
				}
				System.out.println();
			}
			*/


			System.out.println(dp[N][W]);


		}


	}


}


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

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int A,B;
    cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;
    
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val inf = 10000
    val n = readLine()!!.toInt();
    val a = Array(n) { readLine()!!.split(" ").drop(1).map { it.toInt() }.map { if (it < 0) inf else it } }
    val c = Array(n) { 0 }
    val d = Array(n) { inf }
    val p = Array(n) { -1 }
    d[0] = 0
    while (true) {
        var mincost = inf
        var u = -1
        for (i in 0 until n) {
            if (c[i] != 2 && d[i] < mincost) {
                mincost = d[i]
                u = i
            }
        }
        if (u == -1)
            break
        c[u] = 2
        for (j in 0 until n) {
            if (c[j] != 2 && a[u][j] != inf) {
                if (d[j] > a[u][j]) {
                    d[j] = a[u][j]
                    p[j] = u
                    c[j] = 1
                }
            }
        }
    }
    var sum = 0
    for (i in 0 until n) if (p[i] != -1) sum += a[i][p[i]]
    println(sum)
}




Measured memory_bytes: 35724
#include <stdio.h>

int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0) break;
		for(int i = 0; i < x; i++){   //縦のループ
			for(int j = 0; j < y; j++){  //横のループ
				if(i == 0 || i == x-1){  //1行目とx行目を全て#にする
				printf("#");
				}
				else if(i != 0 && i != x-1 && j == 0 || j == y-1){  //1行目、x行目以外の1列目とy列目を全て＃にする
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL mi(LL a,int b){
	vector<int>v;
	//cout<<a<<endl;
	while(a!=0){
		v.push_back((a%10));
		a/=10;
		//cout<<"in"<<a%10<<endl;
	}
	for(int i=v.size();i<b;i++){
		v.push_back(0);
	}
	sort(v.begin(),v.end());
	LL now=0;
	REP(i,b){
		now*=10;
		now+=v[i];
	}
	return now;
}

LL ma(LL a,int b){
	vector<int>v;
	while(a!=0){
		v.push_back((a%10));
		a/=10;
	}
	for(int i=v.size();i<b;i++){
		v.push_back(0);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	LL now=0;
	REP(i,b){
		now*=10;
		now+=v[i];
	}
	return now;
}

int main(){
	LL a,b;
	while(cin>>a>>b){
		if(a==0&&b==0)break;
		LL now=0;
		LL o=a;
		map<LL,int>m;
		m[a]=0;
		while(1){
			LL x=mi(o,b);
			LL y=ma(o,b);
			LL nxt=y-x;
			//cout<<x<<" "<<y<<" "<<nxt<<endl;
			if(m.count(nxt)==0){
				now++;
				m[nxt]=now;
				o=nxt;
			}else{
				o=nxt;
				break;
			}
			//cout<<o<<endl;
		}
		cout<<m[o]<<" "<<o<<" "<<now-m[o]+1<<endl;
	}
}


Measured memory_bytes: 3112
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func pow(n int) int {
	var p float64 = math.Pow(float64(n), 2.0)
	return int(p)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := make([]int, n)
	for i := range x {
		x[i] = nextInt()
	}

	sum := 0
	var min int = math.MaxInt64
	for i := 1; i <= 100; i++ {
		for j := 0; j < n; j++ {
			sum += pow(x[j] - i)
		}
		if sum < min {
			min = sum
		}
		sum = 0
	}
	fmt.Println(min)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int n;
      cin>>n;
      int arr[n];
      
      for(int i=0;i<n;i++){
        cin>>arr[i];
        //cout<<arr[i]<<" ";
      }
      //cout<<"\n";
      int dp[n];
      dp[0]=0;
      dp[1]=abs(arr[1]-arr[0]);
      
      for(int i=2;i<n;i++){
     	int a=dp[i-1]+ abs(arr[i]-arr[i-1]);
        int b=dp[i-2]+ abs(arr[i]-arr[i-2]);
        dp[i]=min(a,b);
        //cout<<a<<" "<<b<<" "<<dp[i]<<" ";
      }
    //   for(auto i:dp)
    //     cout<<i<<" ";

      cout<<dp[n-1];
      return 0;
    }

Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>
#define init(A,B) { int i; for(i=0; i<B; i++) A[i]=0; }

#define P_MAX 1000
#define N_MAX 1000

struct data{ int time; char type; int ID; };

int main(void){
	int N;
	
	while(scanf("%d\n",&N), N!=0){
		int i, j=0, k, t[4], max=0, presence[P_MAX], time[P_MAX]; struct data dat[N_MAX];
		init(presence,P_MAX); init(time,P_MAX);
		
		for(i=0; i<N; i++){
			scanf("%2d/%2d %2d:%2d %c %3d\n",&t[0],&t[1],&t[2],&t[3],&dat[i].type,&dat[i].ID);
			dat[i].time=t[3]+60*(t[2]+24*(t[1]+31*t[0]));
		}
		
		for(i=dat[0].time; i<=dat[N-1].time; i++){
			if(dat[j].time==i && j<N){
				while(dat[j].time==i){
					if(dat[j].type=='I') presence[dat[j].ID]=1;
					else presence[dat[j].ID]=0;
					j++;
				}
			}
			if(presence[0]==1) for(k=1; k<P_MAX; k++) time[k]+=presence[k];
		}
		
		for(i=1; i<P_MAX; i++) if(max<time[i]) max=time[i];
		
		printf("%d\n",max);
	}
	
	return 0;
}

Measured memory_bytes: 432
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
#include <iomanip>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


int main()
{
    string S;
    cin>>S;

    int N=S.size();
    int ans=0;
    if(N%2==0){
        REP(i,0,N/2){
            if(S[i]!=S[N-1-i]){
                ans++;
            }
        }
    }else{
        REP(i,0,N/2){
            if(S[i]!=S[N-1-i]){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

//define ll long long;
//define ar array;

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

    int n;
    cin >> n;
    string ans;
    cin.ignore();
    getline(cin, ans);
    if (ans.size() > n){
        ans = ans.substr(0, n);
        cout << ans << "..." << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}



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

#define llt long long int
#define modm 1000000007

int main(){
	int n,m,ans=0;
	string s1,s2;
	cin>>n>>m;
	int num1=n*2,num2=n*4;
	if(m>=num1&&m<=num2){
		if(m%2==0){
			cout<<"Yes"<<endl;
		}
		else
			cout<<"No"<<endl;
		
	}
	else
	cout<<"No"<<endl;
	
}


Measured memory_bytes: 3616
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int HP = sc.nextInt();
		int ATK = sc.nextInt();
		for(int i = 1;;i++){
			HP -= ATK;
			if(HP <= 0){
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 23636
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }

        if (n <= 2) {
            System.out.println(1);
            return;
        }
        int count = 1;
        int previnc = as[0] - as[1];
        for (int i = 2; i < n; i++) {
            int inc = as[i - 1] - as[i];
            if (previnc == 0) {
                previnc = inc;
                continue;
            }
            if (inc == 0) {
                continue;
            }
            // 符号が変わったら増やす
            if (0 < previnc && inc < 0 || previnc < 0 && 0 < inc) {
                previnc = 0;
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 50016
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    if (N % K == 0) {
      System.out.println("0");
    } else {
      System.out.println("1");
    }
  }
}

Measured memory_bytes: 22740
//long time no ac
#include<bits/stdc++.h>
using namespace std;


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

ll dp[100005],a[100105],n,k;

ll f(ll x)
{
	if(x==n-1)
		return 0;
	if(x>=n)
		return hell;
	if(dp[x]==-1)
	{
		ll i;
		dp[x]=f(x+1)+abs(a[x]-a[x+1]);
		repe(i,1,k+1)
		{
			dp[x]=min(f(x+i)+abs(a[x]-a[x+i]), dp[x]);
		}
	}
	return dp[x];
}


int main()
{
	SPEED;
	ll t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k;
		// n=s.length();
		rep(i,n)
		{
			cin>>a[i];
		}
		dp[0]=0;
		repe(i,1,n)
		{
			dp[i]=1e18;
			for (j = 1;  j<=k && i-j>=0 ; ++j)
			{
				dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]), dp[i]);
			}
			// cout<<i<<"&(*"<<dp[i]<<"&\n";
		}
		cout<<dp[n-1];
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	int sum, tmp;
	sum = 0;
	tmp = n;
	while(n)
	{
		sum += n % 10;
		n /= 10;
	}
	if (tmp % sum == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#define MAX_G 82
#define BASE (MAX_G*2)*MAX_G
#define MAX_V BASE * 2
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll grid[MAX_G][MAX_G];
bool dp[MAX_G][MAX_G][MAX_V]={};
signed main(){
  ll a,b,ans=1000000000;
  ll h,w;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a;
      grid[i][j] = a;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> b;
      grid[i][j] = abs(grid[i][j]-b);
    }
  }
  dp[0][0][BASE+grid[0][0]]= true;
  dp[0][0][BASE-grid[0][0]]= true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i==0&&j==0) continue;
      for(int k=0;k<MAX_V;k++){
        if(i!=0&&dp[i-1][j][k]){
          dp[i][j][k+grid[i][j]] = true;
          dp[i][j][k-grid[i][j]] = true;
        }if(j!=0&&dp[i][j-1][k]){
          dp[i][j][k+grid[i][j]] = true;
          dp[i][j][k-grid[i][j]] = true;
        }
      }
    }
  }
  for(int k=0;k<MAX_V;k++){
    if(dp[h-1][w-1][k]){
      ans = min(ans,llabs(k-BASE));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 171264
#include<iostream>
#include<vector>

using namespace std;

struct DATA{
  int x;
  int y;
  int z;
};

int main(){
  int i, a, b, c, n, x, y, z, r;
  DATA _dataNO;
  vector<DATA> dataNO;

  while(1){
    cin >> a >> b >> c;
    if(a == 0 && b == 0 && c == 0) break;

    vector<int> data(a+b+c, 2);
    cin >> n;

    for(i=0; i<n; ++i){
      cin >> x >> y >> z >> r;

      if(r == 1){
	data[x-1] = 1;
	data[y-1] = 1;
	data[z-1] = 1;
      }else{
	_dataNO.x = x-1;
	_dataNO.y = y-1;
	_dataNO.z = z-1;
	dataNO.push_back(_dataNO);
      }
    }

    for(i=0; i<dataNO.size(); ++i){
      if(data[dataNO[i].x] == 1 && data[dataNO[i].y] == 1)
	data[dataNO[i].z] = 0;
      else if(data[dataNO[i].x] == 1 && data[dataNO[i].z] == 1)
	data[dataNO[i].y] = 0;
      else if(data[dataNO[i].y] == 1 && data[dataNO[i].z] == 1)
	data[dataNO[i].x] = 0;
    }

    for(i=0; i<data.size(); ++i)
      cout << data[i] << endl;

    dataNO.clear();
  }
  return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n;
  cin >> n;

  vector<int> a(200010);

  REP(i, 200010) { a[i] = 0; }

  vector<int> b(n);

  REP(i, n - 1) {
    cin >> b[i];
    a[b[i] - 1]++;
  }

  REP(i, n) { cout << a[i] << "\n"; }
}

Measured memory_bytes: 4780
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    vector<int>h(n);
    for(auto & x : h){
        cin >> x;
    }
    auto dif = numeric_limits<double>::max();
    auto ans = 0;
    for(auto i = 0; i < n; ++i){
        auto temp = t - 0.006 * h[i];
        auto difc = fabs(temp - a);
        if(dif > difc){
            ans = i + 1;
            dif = difc;
        }
    }
    cout << ans;
    return 0;
}



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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXN = 105;

char str[MAXN], temp[2][MAXN];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n;
    scanf(" %s", str);
    n = strlen(str);
    vector<char> vec;
    for (int i = 0; i < n; i++) {
        vec.pb(str[i]);
    }
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
    int ans = 1e9;
    for (auto it : vec) {
        strcpy(temp[n & 1], str);
        for (int i = n - 1; i >= 0; i--) {
            int now = i & 1, bef = (i + 1) & 1;
            bool found = true;
            for (int j = 0; j < i + 1; j++)
                if (temp[bef][j] != it)
                    found = false;
            if (found) {
                //printf("found at length %d with char |%c|\n", i + 1, it);
                ans = min(ans, n - i - 1);
                break;
            }
            for (int j = 0; j < i; j++)
                if (temp[bef][j] == it)
                    temp[now][j] = temp[bef][j];
                else
                    temp[now][j] = temp[bef][j + 1];
        }
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i = 0;i<n;i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    long long ans = 0;
    long long cnt = 1;
    for(int i = 0;i<n-1;i++){
        if(s[i]==s[i+1]) cnt++;
        else{
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
    }
    ans+=cnt*(cnt-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 7296
import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


if __name__ == '__main__':
    n=int(input())
    x=primes(55555)
    ans=[]
    for i in x:
      if i % 5==1:
        ans.append(i)
    print(*ans[:n])

Measured memory_bytes: 5272
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B,ans;
  cin>>A>>B;
  for(int k=0;k<1000000000;k++){
    if(abs(A-k)==abs(B-k)){
      cout<<k<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m ;
	cin >>n >>m;
	VL l(m), r(m);
	rep(i, m) cin>>l[i] >>r[i];
	ll ml=-1LL<<60, mr=1LL<<60;
	rep(i, m){
		ml = max(l[i], ml);
		mr = min(r[i], mr);
	}
	//dbg(ml, mr);
	ll ans = mr+1 -ml;
	if(ans < 0) puts("0");
	else cout << ans  <<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[a[i]] == i) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 3716
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int max1 = a[n - 1];
  int max2;
  int c = max1;
  for (int i = 0; i < n; i++) {
    if (fabs(a[i] - max1 / 2) <= c) {
      c = abs(a[i] - max1 / 2);
      max2 = a[i];
    }
    if (max1 == max2)
      max2 = a[i - 1];
  }
  cout << max1 << ' ' << max2 << endl;
  return 0;
}


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            long n = Input();
            var cnts = new Dictionary<string,int>();
            long ans = 0;
            
            
            for(int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                char[] ss = new char[10];
                for(int j = 0; j < 10; j++)
                {
                    ss[j] = s[j];
                }
                Array.Sort(ss);
                s = "";
                for(int j = 0; j < 10; j++)
                {
                    s += ss[j];
                }


                if (cnts.ContainsKey(s)) cnts[s]++;
                else cnts.Add(s, 1);

            }

            foreach(var cnt in cnts)
            {
                if(cnt.Value>=2)ans += Choose(cnt.Value,2);
            }
            Console.WriteLine(ans);
                
                





        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


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

#define int long long
#define ll long long
#define pb push_back

main(){
    int n, m;
    cin >> n >> m;
    int a[n];
    int summ = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        summ += a[i];
    }
    sort(a, a + n);
    if (a[n - m] * 4 * m < summ){
        cout << "No";
    }
    else{
        cout << "Yes";
    }
}



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

int main(){
    int n;
    cin>> n;
    
    int answer;
    for(int i = 1; i < n + 1; i++){
        string s = to_string(i);
        if(s.size() % 2 == 1){
            answer++;
        }
    }
    
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char c;
	scanf("%c", &c);

	if(c == 'A'){
		printf("T\n");
	} else if(c == 'T'){
		printf("A\n");
	} else if(c == 'G'){
		printf("C\n");
	} else if(c == 'C'){
		printf("G\n");
	} else {
		abort();
	}
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void) {
   char X, Y;
   scanf("%c %c", &X, &Y);
   if (X < Y) {
      printf("<\n");
   } else if (X > Y) {
      printf(">\n");
   } else {
      printf("=\n");
   }
   return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int a,b,c,k;
int main() {
  
  scanf("%d %d",&a,&b);   
  
  k=(a+b)/2;
  c=(a+b)%2;
  
 if(c==0)
   {printf("%d\n",k);} 
 else
   {printf("IMPOSSIBLE\n");}
  return 0;
}

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

using namespace std;

const int MAX = 1001;
typedef pair<int,int> P;
typedef pair<P,P> PP;
vector<PP> V;
int goal[MAX];
int n,m,h,k;
int finish[MAX];

void init(){
  V.clear();
}


void make(){

  int nowpos[MAX];

  for(int i = 1; i < MAX; i++)
    nowpos[i] = i;

  for(int i = 0; i < V.size(); i++){
    PP pp = V[i];
    int m = pp.first.second;

    pp.second = P(nowpos[m],nowpos[m+1]);
    V[i] = pp;
    swap(nowpos[m],nowpos[m+1]);
  }

  for(int i = 1; i < MAX; i++)
    finish[nowpos[i]] = goal[i];
}

void print(){
  for(int i = 1; i <= n; i++)
    cout << finish[i] << " ";
  cout << endl;
}

void solve(){

  // print();
  int ans = 0;
  for(int i = 1; i <= k; i++)
    ans += finish[i];

  for(int i = 0; i < V.size(); i++){
    int sum = 0;
    P p = V[i].second;

    swap(finish[p.first],finish[p.second]);

    for(int i = 1; i <= k; i++)
      sum += finish[i];

    ans = min(ans,sum);

    swap(finish[p.first],finish[p.second]);
  }

  cout << ans << endl;
}

int main(){

  while(cin >> n >> m >> h >> k && n+m+h+k){
    init();

    for(int i = 1; i <= n; i++)
      cin >> goal[i];

    for(int i = 0; i < m; i++){
      P p;
      cin >> p.second >> p.first;
      PP pp = PP(p,P(0,0));
      V.push_back(pp);
    }
    sort(V.begin(),V.end());

    make();
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3160
H,W = map(int,input().split())
S = [input() for i in range(H)]

dxy = [(0,1),(1,0),(0,-1),(-1,0)]
from collections import deque
ans = 0
for y in range(H):
    for x in range(W):
        if S[y][x] == '#': continue
        dist = [[0]*W for i in range(H)]
        visited = [[0]*W for i in range(H)]
        visited[y][x] = 1
        q = deque([(x,y)])
        while q:
            x,y = q.popleft()
            for dx,dy in dxy:
                nx,ny = x+dx,y+dy
                if not 0 <= nx < W: continue
                if not 0 <= ny < H: continue
                if visited[ny][nx]: continue
                if S[ny][nx] == '#': continue
                visited[ny][nx] = 1
                dist[ny][nx] = dist[y][x] + 1
                q.append((nx,ny))


        for i in range(H):
            ans = max(ans, max(dist[i]))
        #ans = max(ans, max(max(row) for row in dist))
print(ans)



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

int main() {
	string s; cin >> s;
	vector<ll> dp(13, 0); dp[0] = 1;
	for (int i = 0; i < s.size(); ++i)
	{
		vector<ll> dpp(13, 0);
		if (s[i] == '?')
		{
			for (int j = 0; j < 13; ++j)
			{
				for (int k = 0; k < 10; ++k)
				{
					dpp[(10*j+k)%13] += dp[j];
					dpp[(10*j+k)%13] %= MOD;
				}
			}
		}
		else
		{
			for (int j = 0; j < 13; ++j)
			{
				ll k = s[i]-'0';
				dpp[(10*j+k)%13] = dp[j];
			}
		}
		for (int j = 0; j < 13; ++j)
		{
			dp[j] = dpp[j];
		}
	}
	cout << dp[5] << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
typedef long long ll;
typedef pair<ll, ll> P;
map<long long, long long> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
signed main() {
    ll n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1000 - n % 1000 << endl;
}

Measured memory_bytes: 3692
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        txy_: [[i32; 3]; n]
    }
    let mut txy = vec![vec![0, 0, 0]];
    txy.extend_from_slice(txy_.as_slice());
    let mut reachable = true;
    for i in 0..n {
        let dt = txy[i + 1][0] - txy[i][0];
        let dist = (txy[i + 1][1] - txy[i][1]).abs() + (txy[i + 1][2] - txy[i][2]).abs();
        if dt < dist {
            reachable = false;
            break;
        }
        if (dt % 2) != (dist % 2) {
            reachable = false;
            break;
        }
    }
    println!("{}", if reachable { "Yes" } else { "No" });
}


Measured memory_bytes: 16636
n = int(input())
v = list(map(int, input().split()))

odd = {}
even = {}

for i in range(len(v)):
    if i % 2 == 1:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1
    else:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1

#ソートして一番目、二番目を見る
odd_sorted  = sorted(odd.items(), key = lambda x : -x[1])
even_sorted  = sorted(even.items(), key = lambda x : -x[1])




#候補が同じ場合
if odd_sorted[0][0] == even_sorted[0][0]:
    #奇数も偶数も2番目が存在する？
    if len(odd.keys()) > 1 and len(even.keys()) > 1:
        #数が大きい方を採用
        if odd_sorted[0][1] > even_sorted[0][1]:
            ans_odd = odd_sorted[0][0]
            ans_even = even_sorted[1][0]
        elif odd_sorted[0][1] < even_sorted[0][1]:
            ans_odd = odd_sorted[1][0]
            ans_even = even_sorted[0][0]
        else:
            #両者が一致した場合
            if odd_sorted[1][1] >= even_sorted[1][1]:
                ans_odd = odd_sorted[1][0]
                ans_even = even_sorted[0][0]
            elif odd_sorted[1][1] < even_sorted[1][1]:
                ans_odd = odd_sorted[0][0]
                ans_even = even_sorted[1][0]

    #お互いに二番目が存在しない(ただし数は必ず一致するのでどちらか)
    elif len(odd.keys()) == 1 and len(even.keys()) == 1:
        ans_odd = -1
        ans_even = even_sorted[0][0]
    #奇数に2番目が存在しない
    elif len(odd.keys()):
        ans_odd = odd_sorted[0][0]
        ans_even = even_sorted[1][0]
    #偶数に2番目が存在しない
    else: #len(even.keys()):
        ans_odd = odd_sorted[1][0]
        ans_even = even_sorted[0][0]

else:
    ans_odd = odd_sorted[0][0]
    ans_even = even_sorted[0][0]

ans = 0
for i in range(len(v)):
    if i % 2:
        if v[i] != ans_odd:
            ans += 1
    else:
        if v[i] != ans_even:
            ans += 1



print(ans)

Measured memory_bytes: 20892
def resolve():
    import collections
    n = int(input())
    c = list(collections.Counter([input() for _ in range(n)]).most_common())
    s = []
    m = c[0][1]
    for i in c:
        if i[1] !=m:
            break
        s.append(i[0])
    s.sort()
    print("\n".join(s))
resolve()

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> snuke(N);
    int d, A;
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> A;
            snuke[A - 1] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (!snuke[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var N, W int
	fmt.Scan(&N, &W)
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, 1000000)
	}

	for i := 0; i < N; i++ {
		for sw := 0; sw <= W; sw++ {
			if sw-w[i] >= 0 {
				dp[i+1][sw] = max(dp[i+1][sw], dp[i][sw-w[i]]+v[i])
			}
			dp[i+1][sw] = max(dp[i+1][sw], dp[i][sw])
		}
	}

	fmt.Println(dp[N][W])
}

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


Measured memory_bytes: 308608