akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void Solve()
    {
        int n = cin.Nextint, q = cin.Nextint;
        var P = new BIT(n + 1);
        var Q = new BIT(n + 1);

        for (int i = 0; i < q; i++)
        {
            if (cin.Nextint == 0)
            {
                int a = cin.Nextint, b = cin.Nextint, x = cin.Nextint;
                P.Add(a, -a * x); P.Add(b + 1, (b + 1) * x);
                Q.Add(a, x); Q.Add(b + 1, -x);
            }
            else
            {
                int a = cin.Nextint, b = cin.Nextint;
                Console.WriteLine(P.Sum(b + 1) - P.Sum(a) + (b + 1) * Q.Sum(b + 1) - a * Q.Sum(a));
            }
        }
    }

}

class BIT //[1, n]
{
    int n;
    long[] bit;

    public BIT(int N)
    {
        n = N;
        bit = new long[n + 1];
    }

    public void Add(int i, long x)
    {
        while (i <= n)
        {
            bit[i] += x;
            i += i & -i;
        }
    }

    // [1, i] sum
    public long Sum(int i)
    {
        long s = 0;
        while(i > 0)
        {
            s = s + bit[i];
            i -= i & -i;
        }
        return s;
    }

    //[a, b] sum
    public long Sum(int a, int b)
    {
        return Sum(b) - Sum(a - 1);
    }
}
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11932
def main():
    N = int(input())
    A = list(map(int, input().split()))

    d = {}
    for ai in A:
        if d.get(ai):
            d[ai] += 1
        else:
            d[ai] = 1

    # print(d)
    ans = 0
    for k, v in d.items():
        if k <= v:
            ans += v - k
        else:
            ans += v

    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 17780
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  map<string,int> mp;
  rep(i,n){
    mp[s[i]]++;
  }

  int mx=0;
  for(auto it=mp.begin();it!=mp.end();++it){
    mx = max(mx,it->second);
  }

  for(auto it=mp.begin();it!=mp.end();++it){
    if(it->second==mx) cout << it->first << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 26752
while true
    a,b = gets.split.map{|x| x.to_i}
    exit if [a,b].uniq==[0]
    n = gets.to_i

    kouji = []
    n.times do kouji << gets.split.map{|x| x.to_i-1} end


    map=[]
    a.times do map << Array.new(b,nil) end
    kouji.each do |k| map[k[0]][k[1]] = 0 end

    map[0][0]=1
    a.times do |x|
        b.times do |y|
            (map[x][y] = map[x-1][y]; next) if (y==0)&&(map[x][y]==nil)
            (map[x][y] = map[x][y-1]; next) if (x==0)&&(map[x][y]==nil)
            map[x][y] = map[x-1][y] + map[x][y-1] if map[x][y]==nil
        end
    end

    puts map[a-1][b-1]

end

Measured memory_bytes: 7092
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val s = sc.next
  val n = s.length

  def loop(str: String): String ={
    val l = str.length
    if(l < n && str.substring(0,l/2) == str.substring(l/2)) str
    else loop(str.substring(0,l - 2))
  }

  val res = loop(s).length

  println(res)
}

Measured memory_bytes: 25792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[200005], s[200005];
map<llint, llint> mp;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) s[i] = s[i-1] + a[i], s[i] %= k;
	for(int i = 1; i <= n; i++) s[i] += k-i%k, s[i] %= k;
	
	//for(int i = 0; i <= n; i++) cout << s[i] << " "; cout << endl;
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		ans += mp[s[i]];
		mp[s[i]]++;
		if(i-(k-1) >= 0) mp[s[i-(k-1)]]--;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>
#define ll long long
const int mod = 1e9 + 7;

int n;

int mx[21][21];

ll dp[21][ (1<<21) ];

ll cal(int x,int k){
	if (dp[x][k]!=-1) return dp[x][k];
	ll val = 0;
	for(int i=0;(1<<i) <= k;i++){
		if(!(k>>i&1)) continue;
		if(mx[x][i]==0) continue;
		if (x==n-1){
			val=1;
			break;
		}
		val += cal( x+1 , ( k&(~(1<<i)) ) ) ;
		if (val>mod) val-=mod;
	}
	return dp[x][k]=val;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) 
	for(int j=0;j<n;j++)
		scanf("%d",&mx[i][j]);
	memset(dp,-1,sizeof dp );
	printf("%lld\n", cal(0, (1<<n)-1 ) );
}

Measured memory_bytes: 345792
N,K=map(int,input().split())
S=input()
ans=""
for x in range(N):
  if x!=K-1:
    ans+=S[x]
  else:
    if S[x]=="A":
      ans+="a"
    elif S[x]=="B":
      ans+="b"
    elif S[x]=="C":
      ans+="c"
print(ans)

Measured memory_bytes: 9196
n = int(input())
s = []
t = []

for i in range(0, n):
    si, ti = map(str, input().split())
    s.append( si)
    t.append( int(ti) )

x = input()

sum = 0
sleeping = False
for i in range(0, n):
    if sleeping:
        sum += t[i]
    if s[i] == x:
        sleeping = True

print(sum)


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

half=sum(a)//2

ans=""
# for i in range(n):
#     tmp=half
#     for j in range(i+1, n, 2):
#         tmp-=a[j]
#     if i%2==0:
#         for j in range(0, i, 2):
#             tmp-=a[j]
#     else:
#         for j in range(1, i, 2):
#             tmp-=a[j]
#     ans+=str(tmp*2)
#     if i!= n-1:
#         ans+=" "
gu=[]
syaku=0
for i in range(1,n,2):
    syaku+=a[i]
for i in range(0,n,2):
    gu.append((half-syaku)*2)
    syaku+=a[i]
    if i+1==n:
        syaku-=a[0]
    else:
        syaku-=a[i+1]
# print(gu)
ki=[]
syaku=0
for i in range(2,n,2):
    syaku+=a[i]
for i in range(1,n,2):
    ki.append((half-syaku)*2)
    syaku+=a[i]
    if i+1==n:
        syaku-=a[0]
    else:
        syaku-=a[i+1]
# print(ki)
ans=[]
for i in range(n//2):
    ans.append(gu[i])
    ans.append(ki[i])
ans.append(gu[n//2])

print(" ".join(map(str, ans)))

Measured memory_bytes: 86116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
    ll N;
    cin >> N;
    ll ans=-1;
    ll max=sqrt(N)/1;
    for(ll i=max;i>0;i--){
        if(N%i==0){
            ll s=N/i;
            ans=i+s-2;
            cout << ans << endl;
           return 0;
        }
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,i;
  cin >> s;
  i = s % 10;
  s = s / 10;
  i = i + s % 10;
  s = s / 10;
  i = i + s;
  cout << i << endl;
}

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

int main(){
  int n; bitset<15> bb;
  cin >> n;
  vector<vector<int>> syogen(n,vector<int>(n,-1));
  for(int i=0;i<n;i++){
    int a; cin >> a;
    for(int j=0;j<a;j++){
      int x,y; cin >> x >> y; syogen.at(i).at(x-1) = y;
    }
  }
  
  int cnt = 0;
  for(int i=0;i<(1<<n);i++){
    bb = i; bool can = true;
    for(int j=0;j<n;j++){
      if(!bb.test(j)) continue;
      for(int k=0;k<n;k++) if( (syogen.at(j).at(k) == 1 && !bb.test(k)) || (syogen.at(j).at(k) == 0 && bb.test(k)) ) can = false;
    }
    if(can) cnt = max(cnt,(int)bb.count());
  }
  cout << cnt << endl;
}

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

int main(){
  double a,b,v,w,t;cin>>a>>v>>b>>w>>t;
  double d=abs(a-b),vv=v-w;
  if(v<=w){
    cout<<"NO";
    return 0;
  }
  double time=d/vv;

  cout<<(time<=t?"YES":"NO");
}

Measured memory_bytes: 3784
N=int(input())
a = []
for i in [0]*N:
	a.append(int(input()))

'''
N=3
a=[100000,30000,20000]
'''

b=[x % 2 for x in a]

s = sum(b)
if s == 0:
	print("second")
else:
	print("first")



Measured memory_bytes: 7840
(H, W) = map(int, input().split())
a = []
for i in range(H):
    a.append(list(map(int, input().split())))
#print("a: ")
#print(a)

odd_flag = []
for i in range(len(a)):
    odd_flag.append(list())
    for j in range(len(a[i])):
        if a[i][j]%2 != 0:
            odd_flag[i].append(True)
        else:
            odd_flag[i].append(False)
#print("odd_flag: ")
#print(odd_flag)

odd_sum = 0
for i in range(len(odd_flag)):
    odd_sum += odd_flag[i].count(True)
#print(odd_sum)

def move(h, w):
    if h%2 == 0:
        if w == W-1:
            return (h+1, w)
        else:
            return (h, w+1)
    else:
        if w == 0:
            return (h+1, w)
        else:
            return (h, w-1)

s_h = 0
s_w = 0
N = 0
ope_list = []
move_flag = False
while odd_sum >= 2:
    # 移動先到着
    if move_flag is True and odd_flag[s_h][s_w] is True:
        move_flag = False
        (s_h, s_w) = move(s_h, s_w)
        odd_sum -= 2
    # 移動中
    elif move_flag is True and odd_flag[s_h][s_w] is False:
        ope = ""
        ope += str(s_h+1) + " " + str(s_w+1) + " "
        (s_h, s_w) = move(s_h, s_w)
        ope += str(s_h+1) + " " + str(s_w+1) + "\n"
        ope_list.append(ope)
        N += 1
    # 移動すべきものなし
    elif move_flag is False and odd_flag[s_h][s_w] is False:
        (s_h, s_w) = move(s_h, s_w)
    # 移動元到着
    elif move_flag is False and odd_flag[s_h][s_w] is True:
        move_flag = True
        ope = ""
        ope += str(s_h+1) + " " + str(s_w+1) + " "
        (s_h, s_w) = move(s_h, s_w)
        ope += str(s_h+1) + " " + str(s_w+1) + "\n"
        ope_list.append(ope)
        N += 1

print(N)
for i in range(len(ope_list)):
    print(ope_list[i], end="")
    print("\n")



Measured memory_bytes: 19524
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int K, X;
	cin >> K >> X;
	for (int i = K - 1; i >= 0; i--) cout << X - i << " ";
	for (int i = 1; i < K; i++) cout << X + i << " ";
	cout << endl;
}

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

int main(int argc, char *argv[]){
        int i=0,j=0;
        for(i = 1; i < 10;i++){
                for(j = 1; j < 10;j++){
                        printf("%dx%d=%d\n",i,j,i*j);
                }
        }
        return 0;
}


Measured memory_bytes: 2060
if __name__ == "__main__":
    str_length = input()
    input_str = input()

    str_length = int(str_length)

    if len(input_str) <= str_length:
        lim_str = input_str
    else:
        lim_str = ''.join([c for c in input_str[0:str_length]])+'...'



    print(lim_str)

Measured memory_bytes: 9176
void main() {
	auto N = ri;
	auto A = [0];
	A ~= readAs!(int[]);
	A ~= 0;
	ulong S;
	foreach(i; 0..N+1) {
		S += abs(A[i] - A[i+1]);
	}
	foreach(i; 1..N+1) {
		(S - abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1])).writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

ulong[] generate_prime_list(T)(T N) if(isIntegral!T) {
	ulong[] prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N.to!ulong+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
	return prime_list;
}

class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n+1;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}


Measured memory_bytes: 5368
#include <stdio.h>

int main(void){
    long int n;
    long int a;
    long int b;
    scanf("%ld %ld %ld",&n,&a,&b);
    if(n%(a+b)<=a){
        printf("%ld",n/(a+b)*a+n%(a+b));
    }
    else{
        printf("%ld",n/(a+b)*a+a);
    }
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template <class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
typedef vector<int>vi;
typedef vector<vi> vvi;
typedef vector<string>vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(A) (A).begin(),(A).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
const double EPS=1e-10;
const double PI= acos(-1.0);

int main(){
	int N, T, L, B;

	while(cin >> N >> T >> L >> B,N) {
		vi  board(N+1);
		vector< vector<double> > table(T+2, vector<double>(N+1));
		
		int masu;
		REP(i, L) {
			cin >> masu;
			board[masu] = 1;
		}
		REP(i, B) {
			cin >> masu;
			board[masu] = 2;
		}

		table[0][0] = 1;
		FOR(t, 0, T) {
			table[t+1][N] += table[t][N];

			FOR(n, 1, N) {
				FOR(d, 1, 6+1) {
					int tmp = n+d;
					if(tmp > N) {
						tmp = 2*N-tmp;
					}

					if(board[n] == 2) {
						table[t][0] += table[t][n];
						table[t][n] = 0;
					} else if(board[n] == 1) {
						table[t+2][tmp] += table[t][n] / 6.0;
					} else {
						table[t+1][tmp] += table[t][n] / 6.0;
					}
				}
			}
			FOR(d, 1, 6+1) {
				int tmp = d;
				if(tmp > N) {
					tmp = 2*N-tmp;
				}
				table[t+1][tmp] += table[t][0] / 6.0;
			}
		}

		double ans = table[T][N];

		printf("%.6f\n", ans);
	}


}

Measured memory_bytes: 1324
using System;

namespace ConsoleApplication41
{
    class Program
    {
        static void Main(string[] args)
        {
            //??¢???????????????????????????
            string[] array = {
                                 "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"
                              };
            int[] sum = new int[array.Length];
            
            while (true)
            {
                string input = Console.ReadLine();
                //???????????£???????????????
                if(input == null || input.Length == 0)
                {
                    break;
                }
                //char?????????
                char[] chr = input.ToCharArray();
                for (int i = 0; i < chr.Length; i++ )
                {
                    //??§??????????°??????????
                    if (char.IsUpper(chr[i]))
                    {
                        chr[i] = char.ToLower(chr[i]);
                    }
                }
                int iLength = chr.Length;
                for (int i = 0; i < iLength; i++)
                {  
                    //string????????´???
                    string p = chr[i].ToString();
                        //???????????????
                        for (int x = 0; x < 26; x++)
                        {
                            if (array[x].Equals(p))
                            {
                                //????????£???????????????
                                if ('a' <= chr[i] || chr[i] <= 'z')
                                {
                                    sum[x] = sum[x] + 1;
                                }
                            }
                        }
                }
             }    
            
          
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i] + " " + ":" + " " + sum[i]);
            }
        }
    }
  }

Measured memory_bytes: 9088
#include<bits/stdc++.h> 
using namespace std; 
const int MAX = 1000001; 
struct Query 
{ 
    int l, r, idx; 
}; 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
int last_visit[MAX];
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
    memset(last_visit, -1, sizeof(last_visit)); 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
int main() 
{ 
    int n,q;
    cin>>n>>q;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    Query queries[q];
    for(int i=0;i<q;i++){
        cin>>queries[i].l>>queries[i].r;
        queries[i].idx=i;
        queries[i].l--;
        queries[i].r--;
    }    
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 19312
import numpy as np
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]

dist = np.zeros((n, m))
for i in range(n):
  for j in range(m):
    dist[i, j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for dis in dist:
  print(dis.argmin()+1)

Measured memory_bytes: 12408
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
using namespace std;

int main() {
  string s;
  cin >> s;
  int flag = 0;
  for (int i=1;i<4;i++){
    if(s[i-1] == s[i]) flag = 1;
  }
  
  if (flag == 0) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;

char in[N];
int dp[N][20], n; // dp[i][j] 代表着前i个字符组成的数字在膜13后的余数为j的个数

int main() {
    scanf("%s", in+1);
    n = (int)strlen(in+1);
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        if (in[i] == '?') {
            //枚举可能的数
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k <= 12; k++) {
                    dp[i][(10 * k + j) % 13] = (dp[i][(10 * k + j) % 13] + dp[i-1][k]) % mod;
                    dp[i][(10 * k + j) % 13] %= mod;
                }
            }
        } 
        else {
            int now = in[i] - '0';
            for (int ii = 0; ii <= 12; ii++) {
                dp[i][(10 * ii + now) % 13] = (dp[i][(10 * ii + now) % 13] + dp[i-1][ii]) % mod;
                dp[i][(10 * ii + now) % 13] %= mod;
            }
        }
    }
    printf("%d\n", dp[n][5]);
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>

int a()
{
    int a;
    std::cin >> a;
    
    bool ans = false;
    if(a / 100 == 7)
    {
        ans = true;
    }
    
    a = a % 100;
    if(a / 10 == 7)
    {
        ans = true;
    }
    
    a = a % 10;
    if(a == 7)
    {
        ans = true;
    }
    
    if(ans)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define INF 1e9
using namespace std;

int main()
{
    int m1,m2,d1,d2;
    cin>>m1>>d1>>m2>>d2;

    cout<<(d2 == 1) ? 1 : 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    auto solve = [](int dif) {
        int count = 1;
        while (dif % 2 != 1) {
            ++count;
            dif /= 2;
        }
        return count;
    };
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            cout << solve(j - i) << (j == N - 1 ? '\n' : ' ');
        }
    }
}


Measured memory_bytes: 512
import numpy as np 
A = [list(map(int, input().split())) for i in range(3)] 
N = int(input()) 
B = [int(input()) for i in range(N)]
C = np.zeros((3,3))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                C[j][k] = 1
                
frag = False
f3,f4 = 0,0
for j in range(3):
    f1,f2 = 0,0 
    for k in range(3):
        f1 += C[j][k]
        f2 += C[k][j]
    if f1 == 3 or f2 == 3:
        frag = True
        break 
    f3 += C[j][j] 
    f4 += C[j][2-j]
    
if f3 == 3 or f4 == 3:
    frag = True
    
if frag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12448
use proconio::input;
 
// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a
 
fn dfs(sta:usize,n:usize,m:usize,retu:&mut Vec<i32>,abcd:&Vec<(i32,i32,i32,i64)>) -> i64 {
    let mut res = 0i64;
    if n  == retu.len() {
        for &(a,b,c,d) in abcd.iter(){
            if retu[(b - 1) as usize] - retu[(a - 1) as usize] == c {
                res += d;
            }
        }
        return res;
    }
    for i in sta..=m{
        retu[n] = i as i32;
        let curres = dfs(i,n + 1,m,retu,abcd);
        if res < curres {
            res = curres;
        }
    }
    res
}
fn main() {
/*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n: usize,
        m: usize,
        q: usize,
        mut abcd: [(i32,i32,i32,i64); q],
    }
 
    let result = dfs(1,0,m,&mut vec![0;n],&abcd);
    println!("{}",result);
}

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

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

    string S;
    string A1, A2;
    int counter1 = 0;
    int counter2 = 0;
    char one='1';
    char zero='0';
    char temp;

    cin >> S;

    temp = one;

    rep(i, S.size())
    {
        A1.push_back(temp);
        if (A1[i] != S[i])
        {
            ++counter1;
        }

        if (temp == one)
        {
            temp = zero;
        }
        else
        {
            temp = one;
        }
    }

    temp = zero;

    rep(i, S.size())
    {
        A2.push_back(temp);
        if (A2[i] != S[i])
        {
            ++counter2;
        }
        if (temp == one)
        {
            temp = zero;
        }
        else
        {
            temp = one;
        }
    }

    cout << min(counter1, counter2);

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  
  int A, B;
  cin >> A >> B;
  cout << max({A+B, A+A-1, B+B-1}) << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
count = 0
m = 0
for i in range(0, n):
  if i == 0:
    count += 1
    m = h[i]
  else:
    if h[i] >= m:
      count += 1
      m = h[i]
print(count)

Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
AB = list(zip(m,m))

# make graph
# graph(x): xと繋がっている頂点（番号）のリスト
graph = [[] for _ in range(N+1)]
for a,b in AB:
  graph[a].append(b)
  graph[b].append(a)

# 深さ優先探索で、頂点の探索順序を作成
root = 1
parent = [0] * (N+1) # parent[x]: xの親の番号
order = [] # 深さ優先探索の順序リスト
stack = [root]
while stack:
  x = stack.pop()
  order.append(x)
  for y in graph[x]:
    if y == parent[x]:
      continue
    parent[y] = x
    stack.append(y)

# color[i]: 頂点iとその親の間の辺の色
color = [-1] * (N+1)

# 頂点の探索順ごとに、頂点とその子の間の辺の色を決定
for x in order:
  ng = color[x] # 頂点xとxの親との間の辺の色
  c = 1
  # 頂点xとつながっている頂点のリストを取得し、辺の色を1から順に割り当てる
  for y in graph[x]:
    if y == parent[x]: # xの親の頂点の場合は何もしない
      continue
    if c == ng: # xとその親との間の辺の色は割り当てないようにする
      c += 1
    color[y] = c
    c += 1

# 回答作成
answer = []
for a,b in AB:
  # aがbの子ならcolor[a]を、逆の場合はcolor[b]を出力する
  if parent[a] == b:
    answer.append(color[a])
  else:
    # 今回の場合、a_i < b_iで、番号の小さい方が親になるように木を作っているので、
    # こちらの条件のほうにしか引っかからないはず
    answer.append(color[b])

K = max(answer) # 色の番号の中で最も大きいものがK
print(K)
print('\n'.join(map(str,answer)))

Measured memory_bytes: 38292
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

i64 N, K; cin >> N >> K;

N = N % K;
if (N > K / 2) cout << K - N << "\n";
else cout << N << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<P> vp;
    vp.eb(s[0] - '0', 0);
    rep(i, n) {
        if (vp.back().fi == s[i] - '0') {
            vp.back().se++;
        } else {
            vp.eb(s[i] - '0', 1);
        }
    }
    int m = sz(vp);
    int r = 0;
    int now = 0;
    int sm = 0;
    int ans = 0;
    for (int l = 0; l < m; ++l) {
        while (now + (vp[r].fi == 0) <= k && r < m) {
            now += (vp[r].fi == 0);
            sm += vp[r].se;
            r++;
        }
        chmax(ans, sm);
        sm -= vp[l].se;
        now -= (vp[l].fi == 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1528
#include<iostream>
#include<string>

using namespace std;

int main(){
  string s;
  cin >> s;
  int cnt1=0, cnt0=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0')cnt0++;
    else cnt1++;
  }
  cout << min(cnt0, cnt1)*2 << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        int a=input.scanInt();
        System.out.println(a+(a*a)+(a*a*a));
    }
}


Measured memory_bytes: 32160
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000
#define VMAX 10000
int main(){//kが要素の最大値                                                 
  int *A,*B;
  int N,C[VMAX+1],i,j,k=0;
  scanf("%d",&N);
   A = malloc(sizeof(int)*N);
  B = malloc(sizeof(int)*N) ;
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
    if(A[i]>k)
      k=A[i];//最大値求めた                                                  
  }
  for(i=0;i<=k;i++)
    C[i]=0;//初期化                                                          

  for(j=1;j<=N;j++)
    C[A[j]]=C[A[j]]+1;//A[i]の出現数を記録する                               

  for(i=1;i<=k;i++)
    C[i]=C[i]+C[i-1];//前の数を足していく                                    
  for(j=N;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }
  for(i=1;i<=N;i++){
    printf("%d",B[i]);
    if(i==N){
      printf("\n");
      break;
    }
    printf(" ");
  }
  return 0;
}






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

int main()
{
  string a;
  getline(cin, a);
  for(int i=0;a[i]!='\0';i++)
  {
    if(((i%2==0) && (a[i]=='R' || a[i]== 'U' || a[i] == 'D')) || ((i%2==1) && (a[i]=='L' || a[i]== 'U' || a[i] == 'D')))
      continue;
    else
    {cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl; return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[2222][2222];
int A[2222];
int n;
int dfs(int l,int r,int f){
  if((r+1)%n==l) return 0; 
  if(~dp[l][r]) return dp[l][r];
  int res=0;
  int nl=(l-1+n)%n,nr=(r+1)%n;
  if(f){
    if(A[nl]>A[nr]) res=dfs(nl,r,0);
    else res=dfs(l,nr,0);
  }else{
    res=max(res,dfs(nl,r,1)+A[nl]);
    res=max(res,dfs(l,nr,1)+A[nr]);
  }
  return dp[l][r]=res;
}
signed main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  memset(dp,-1,sizeof(dp));
  int ans=0;
  for(int i=0;i<n;i++) ans=max(ans,dfs(i,i,1)+A[i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 41764
n = int(input())
for i in range(n) :
    
    first = "OFF"
    second = "OFF"
    third = "OFF"
    score = 0
    out = 0
    
    while True :
        event = input()
        if event == "HIT" :
            if first == "OFF" :
                first = "ON"
            else :
                if second == "OFF" :
                    second = "ON"
                else :
                    if third == "OFF" :
                        third = "ON"
                    else :
                        score += 1
        elif event == "HOMERUN" :
            if first == "ON" :
                score += 1
                first = "OFF"
            if second == "ON" :
                score += 1
                second = "OFF"
            if third == "ON" :
                score += 1
                third = "OFF"
            score += 1
        else :
            out += 1
            if out == 3 :
                print(score)
                break

    


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

int main(){
  
  int N;
  cin >> N;
  int t = N,c = 0,i = 8;
  
  while(i > 0){
    c = c + (t % 10);
    t = t / 10;
    i--;
  }
  if(N % c == 0){
    cout << "Yes" << endl;
  }else if(N % c != 0){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(int x, int y, int mod){
    int ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}


int n = 3010, maxn = 3000;
ll fac[3010], inv[3010];


void init(){
    fac[0]=1;
    REP(i, 1, maxn+1)fac[i]=1ll*fac[i-1]*i%mod;
    inv[maxn]=pow(fac[maxn], mod-2, mod);
    REPR(j,maxn-1,-1)inv[j]=1ll*inv[j+1]*(j+1)%mod;
}



int main() {
    sonic();
    string ans="", s;
    R s;
    rep(i, s.length()) {
        if(s[i]=='1')ans+='1';
        else if(s[i]=='0')ans+='0';
        else ans=ans.substr(0, ans.length()-1);
    }
    co(ans);
}


Measured memory_bytes: 3624
n, L = map(int, input().split())

sum_n = 0
min = 1000
ans = 0

for i in range(1, n+1):
    sum_n += L + i -1

    if(abs(L+i-1) < min):
        min = abs(L+i-1)
        ans = L+i-1
print(sum_n-ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> C(4);
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S=="AC"){
      C.at(0)++;
    }
    if(S=="WA"){
      C.at(1)++;
    }
    if(S=="TLE"){
      C.at(2)++;
    }
    if(S=="RE"){
      C.at(3)++;
    }
  }
  
  cout << "AC x " << C.at(0) << endl;
  cout << "WA x " << C.at(1) << endl;
  cout << "TLE x " << C.at(2) << endl;
  cout << "RE x " << C.at(3) << endl;
    
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int n, m, x, y;
	int x_tmp, y_tmp;
	int x_max = INT_MIN, y_min = INT_MAX;
	scanf("%d %d %d %d\n", &n, &m, &x, &y);
	for(int i=0; i < n; i++){
		scanf("%d", &x_tmp);
		if(x_tmp > x_max) x_max = x_tmp;
	}
	for(int i=0; i < m; i++){
		scanf("%d", &y_tmp);
		if(y_tmp < y_min) y_min = y_tmp;
	}
	if(x_max < y_min && x_max < y && y_min > x)
		printf("No War\n");
	else
		printf("War\n");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : v )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

const ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

class UnionFind {
public:
	UnionFind( int n )
	{
		par.resize( n );
		siz.resize( n );

		rep( i, n )
		{
			par[i] = i;
			siz[i] = 1;
		}
	}

	int find( int x )
	{
		if ( x == par[x] ) return ( x );
		else return ( par[x] = find( par[x] ) );
	}

	void unite( int x, int y )
	{
		int pX = find( x );
		int pY = find( y );
		if ( pX == pY ) return;

		if ( siz[pX] < siz[pY] )
		{
			par[pY] = pX;
			siz[pX] += siz[pY];
		}
		else
		{
			par[pX] = pY;
			siz[pY] += siz[pX];
		}
	}

private:
	vector<int> par;
	vector<int> siz;
};

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

	UnionFind uf( N );
	rep( i, M )
	{
		int x, y, z;
		cin >> x >> y >> z;

		uf.unite( x - 1, y - 1 );
	}

	vector<int> v( N );
	rep( i, N )
	{
		v[i] = uf.find( i );
	}
	sort( ALL( v ) );
	UNIQUE( v );

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

	return ( 0 );
}


Measured memory_bytes: 2688
import numpy as np
from itertools import combinations

N = int(input())

P = [np.array(list(map(int,input().split())), dtype=float) for _ in range(N)]

d2 = lambda v: np.sum(np.square(v))

def radius(A,B,C):
    a = d2(B-C)
    b = d2(C-A)
    c = d2(A-B)

    r = float('inf')
    if c > d2(A+B - 2*C):
        r = min(r, c)

    if a > d2(B+C - 2*A):
        r = min(r, a)

    if b > d2(C+A - 2*B):
        r = min(r, b)

    if r != float('inf'):
        return r/4

    U = a*(b+c-a)*A + b*(c+a-b)*B + c*(a+b-c)*C
    v = a*(b+c-a) + b*(c+a-b) + c*(a+b-c)
    U /= v
    r = d2(U-A)
    return r

if N == 2:
    print(np.linalg.norm(P[0]-P[1])/2)
else:
    print(np.sqrt(max(radius(a,b,c) for a,b,c in combinations(P,3))))


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

using ll=long long;
using namespace std;

int main(){
    ll h,w;
    cin>>h>>w;
    
    if(h==1 || w==1) cout<<1<<endl;
    else if(h*w%2==0) cout<<h*w/2<<endl;
    else cout<<h*w/2+1<<endl;
    
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <stdexcept>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int S[100];
    string A;
    int x=0;
    while(cin >> A){
        if(A=="+"){
            x--;
            S[x]=S[x+1]+S[x];
        }
        else if(A=="-"){
            x--;
            S[x]=S[x]-S[x+1];
        }
        else if(A=="*"){
            x--;
            S[x]=S[x]*S[x+1];
        }
        else{
            x++;
            S[x]=std::atoi(A.c_str());
        }
    }
    cout << S[1] << endl;
}


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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
const long long mo =  998244353;
vector<int> v[maxi];
long long c[1010][1010];
string s;
int n,m,a,b;

int main()
{
   cin>>n>>m>>a>>b;


  for (int i=1;i<=n;i++){

    for (int j=1;j<=m;j++)
     if ((j<=a && i<=b) || (j>a && i>b))
     printf("1"); else
     printf("0");

     printf("\n");
 }


    return 0;
}
//sanjao sam ruke njene
//da je sada pored mene


Measured memory_bytes: 26496
def solve():
    N,M = map(int, input().split())
    if N == 1 and M == 0:
        return 1
    elif N == 1 and M == 1:
        return 0
    elif N == 2 and M == 0:
        return 2
    elif N == 2 and M == 1:
        return 1
    elif N == 2 and M == 2:
        return 0
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 460020