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

vector<int> Z_algorithm(string S){
  int c = 0, n = S.length();
  vector<int> Z(n,0);
  for(int i = 1; i < n; ++i){
    int l = i - c;
    if(i + Z[l] < c + Z[c]){
      Z[i] = Z[l];
    }else{
      int j = max(0, c + Z[c] - i);
      while(i + j < n && S[j] == S[i+j]) ++j;
      Z[i] = j;
      c = i;
    }
  }
  Z[0] = n;
  return Z;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i) cin >> B[i];
  const long long INF = 1e18;
  vector<long long> X(N,0);
  for(int i = 0; i < 30; ++i){
    string a0(N,'0'), a1(N,'1'), b(N,'0');
    for(int j = 0; j < N; ++j){
      a0[j] += (A[j]>>i)&1;
      a1[j] -= (A[j]>>i)&1;
    }
    for(int j = 0; j < N; ++j)
      b[j] += (B[j]>>i)&1;
    string ba0 = b + "$" + a0 + a0;
    string ba1 = b + "$" + a1 + a1;
    auto Z0 = Z_algorithm(ba0), Z1 = Z_algorithm(ba1);
    // cerr << i << " " << ba0 << " " << ba1 << endl;
    for(int j = 0; j < N; ++j){
      if(Z0[j+N+1] >= N){
        continue;
      }else if(Z1[j+N+1] >= N){
        X[j] += (1<<i);
      }else{
        X[j] = -INF;
      }
    }
  }
  // for(auto x : X){
  //   cerr << x << endl;
  // }
  for(int i = 0; i < N; ++i){
    if(X[i] < 0) continue;
    cout << i << " " << X[i] << endl;
  }
}


Measured memory_bytes: 10516
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;



int main(void){
    
    int N;
    scanf("%d", &N);
    string S;
    cin >> S;
    int lr[2*N];// r:0 l:1
    for(int i=0;i<2*N;i++){
        if(i%2==0){
            if(S[i]=='B'){
                lr[i]=1;
            }
            else{
                lr[i]=-1;
            }
        }
        else{
            if(S[i]=='B'){
                lr[i]=-1;
            }
            else{
                lr[i]=1;
            }
        }
    }
    long long ans=1;
    long long sum=0;
    for(int i=0;i<2*N;i++){
        if(lr[i]== -1){
            if(sum<=0){
                printf("0");
                return 0;
            }
            else{
                ans*=sum;
                ans%=MOD;
            }
        }
        sum+=lr[i];
    }
    if(sum!=0)ans=0;
    for(long long i=1;i<=N;i++)ans=(ans*i)%MOD;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 1284
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String s1=reader.nextLine();
		String s2=reader.nextLine();
		int cont=0;
		if(s1.charAt(0) == s2.charAt(0))
				++cont;
		if(s1.charAt(1) == s2.charAt(1))
			++cont;
		if(s1.charAt(2) == s2.charAt(2))
			++cont;
		System.out.println(cont);
	}

}


Measured memory_bytes: 23124
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    if n == 3:
        print(max(a))
        return
    dp = [[-inf] * 3 for i in range(n + 1)]
    dp[0] = [0, 0, 0]
    dp[1][0] = a[0]
    dp[2][1] = a[1]
    for i in range(3, n+1):
        dp[i][0] = dp[i - 2][0] + a[i-1]
        dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i-1]
        dp[i][2] = max(dp[i - 2][2], dp[i - 3][1], dp[i - 4][0]) + a[i-1]
    if n & 1:
        print(max(dp[-3][0], dp[-2][1], dp[-1][2]))
    else:
        print(max(dp[-1][1], dp[-2][0]))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 136724
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut ab: Vec<(usize, usize)> = (0..m).map(|x| parse!(it, 2)).collect();
    ab.sort_by_key(|x| x.1);
    let mut ret = 1;
    let mut x = ab[0].1;
    for &(a, b) in &ab[1..] {
        if a >= x {
            x = b;
            ret += 1;
        }
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 8444
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long i=0,n,m=1,c=0,a[114514];
	for(cin>>n;i<n;cin>>a[i++]);
	sort(a,a+n);
	for(i=n-1;i>0;i--)
	{
		if(a[i]==a[i-1])
		{
			c++;
			m*=a[i];
			i--;
			if(c==2)
			{
				cout<<m<<endl;
				return 0;
			}
		}
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

namespace AOJ.intro
{
    namespace ITP_1_5_B
    {
        static public class PrintAFrame
        {
            static public void Main()
            {
                while (true)
                {
                    int[] size = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), delegate(string value)
                    {
                        return int.Parse(value);
                    });
                    int H = size[0];
                    int W = size[1];
                    if (H == 0 && W == 0) break;
                    if (H < 3 || W < 3)
                    {
                        Console.WriteLine("3以上いれてください。"); return;
                    }
                    for (int i = 0; i < H; i++)
                    {
                        for (int j = 0; j < W; j++)
                        {
                            if(i == 0 || i == H - 1 || j == 0 || j == W - 1)
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                        Console.WriteLine();
                    }
                    Console.WriteLine();
                }
            }

        }
    }
}


Measured memory_bytes: 8832
#include <stdio.h>

#define MAX 25

typedef struct{
  int l,r,par;
} node;

node N[MAX];

void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int n,i,id,l,r;
  int p;
  
  scanf("%d" ,&n); 
  init(n);

  for(i = 0 ; i < n ; i++){
    if(i<n)break;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);

    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
      p = i;
      break;
    }
  }

  
  puts("Preorder");
  Preorder(p);
  puts("");

  puts("Inorder");
  Inorder(p);
  puts("");

  puts("Postorder");
  Postorder(p);
  puts("");

  return 0;
}

void init(int n){
  int i;

  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}

void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}

void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}

void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x;
  string Si;
  x = 0;
  cin >> N;
  for (int i; i < N; i++) {
    cin >> Si;
  if (Si == "Y") {
    x++;
  }
  else if (Si != "Y") {
    x = x;
  }
  }
  if (x == 0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}


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

import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

X = sorted(list(itertools.permutations(P)))

a = 0
b = 0

for i, v in enumerate(X):
    if v == P:
        a = i
    if v == Q:
        b = i

print(abs(a-b))



Measured memory_bytes: 45552
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int f(int i) {
    int r = 0;
    while (i) {
        r += i % 10;
        i /= 10;
    }
    return r;
}

int main() {
    int n;
    cin >> n;

    int r = 1 << 30;
    for (int i = 1; i < n; i++) {
        int j = n - i;
        r = min(r, f(i) + f(j));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <long long mod>
struct modular {
    long long value;
    modular(long long x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        long long a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            long long t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular operator-() { return modular(-value); }
    modular operator+(modular rhs) { return modular(*this) += rhs; }
    modular operator-(modular rhs) { return modular(*this) -= rhs; }
    modular operator*(modular rhs) { return modular(*this) *= rhs; }
    modular operator/(modular rhs) { return modular(*this) /= rhs; }
    bool operator==(modular rhs) { return value == rhs.value; }
    bool operator!=(modular rhs) { return value != rhs.value; }
    bool operator<(modular rhs) { return value < rhs.value; }
};
template <long long mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
};
const long long mod = (long long)1e9 + 7;
using mint = modular<mod>;

inline mint pw(mint a, long long n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
        }
        a *= a;
        n >>= 1;
    }
    return res;
}
vector<mint> fact, finv;
inline void cinit(int n) {
    fact.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fact[i] = fact[i - 1] * i;
    }
    finv[n - 1] /= fact[n - 1];
    for (int i = n - 2; i >= 2; i--) {
        finv[i] = finv[i + 1] * (i + 1);
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
}
inline mint H(int n, int k) {
    return C(n + k - 1, k);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    cinit(300000);
    mint ans = C(h + w - 2, h - 1);
    for (int i = h - a; i < h; i++) {
        ans -= C(i + b - 1, i) * C(w - b - 1 + h - i - 1, w - b - 1);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
struct Point{
	short x,y;
};
int dot(Point p1, Point p2){ return p1.x*p2.x+p1.y*p2.y; }
int cross(Point p1, Point p2){ return p1.x*p2.y-p1.y*p2.x; }
int main(){
	short q, temp[8];
	Point p1,p2;
	scanf("%hd", &q);
	while(q--){
		for(short i=0;i<8;i++)
			scanf("%hd", &temp[i]);
		p1.x = temp[2]-temp[0]; p1.y = temp[3]-temp[1];
		p2.x = temp[6]-temp[4]; p2.y = temp[7]-temp[5];
		if(cross(p1, p2) == 0) printf("2\n");
		else if(dot(p1, p2)==0) printf("1\n");
		else printf("0\n");
	}
}


Measured memory_bytes: 2656
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		
		for (int i = 0; i < adjMatrix.length; i++) {
			for (int j = 0; j < adjMatrix[0].length; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		
		for (int i = 0; i < totalVertex; i++) {
			LinkedList<Integer> list = adjList.get(i);
			for (int j = 0; j < list.size(); j++) {
				adjMatrix[i][list.get(j)] = 1;
			}
		}
		
		String ans = "";
		for (int i = 0; i < adjMatrix.length; i++) {
			for (int j = 0; j < adjMatrix[0].length; j++) {
				if (j == adjMatrix[0].length - 1) {
					ans += adjMatrix[i][j];
				} else {
					ans += adjMatrix[i][j] + " ";
				}
			}
			ans += "\n";
		}
		
		System.out.print(ans);
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}



Measured memory_bytes: 284520
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     unsigned long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
 int h,w;
 s2(h,w);
 if(h == 1 || w == 1){
     out<<1<<endl;
     return;
 }
 out<<((h+1)/2)*((w+1)/2) + (h/2)*(w/2)<<endl;
}

class BBishop {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        in.tie(0);out.tie(0);
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	BBishop solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
#a
"""
import math
a, b = map(str, input().split())
j = int(a + b)
if math.sqrt(j).is_integer():
    print("Yes")
else:
    print("No")
"""

#b
"""
ans = ["Positive","Negative"]
a, b = map(int, input().split())
if 0 < a:
    print("Positive")
elif b >= 0:
    print("Zero")
else:
    print(ans[(b-a)%2-1])
"""

#C
import itertools
n = int(input())
MARCH = ["M", "A", "R", "C", "H"]
march = [0 for _ in range(5)]
for i in range(n):
    s = input()
    if s[0] in MARCH:
        march[MARCH.index(s[0])] += 1
num = list(range(5))
a = list(itertools.combinations(num, 3))
ans = 0
for i in a:
    bf = 1
    for k in i:
        bf *= march[k]
    ans += bf
print(ans)
        


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, M, K;
	cin >> N >> M >> K;
	vector<ll> A;
	vector<ll> B;
	for (int i = 0; i < N; i++)
	{
		ll temp;
		cin >> temp;
		if (i > 0)
			A.push_back(temp + A[i - 1]);
		else
			A.push_back(temp);
	}

	for (int i = 0; i < M; i++)
	{
		ll temp;
		cin >> temp;
		if (i > 0)
			B.push_back(temp + B[i - 1]);
		else
		{
			B.push_back(temp);
		}
	}
	ll ans = 0;
	auto it = upper_bound(B.begin(), B.end(), K);
	// cout <<temp<<" "<<*it<<endl;
	// if(*it <= temp)
	ans = max(ans, ll(it - B.begin()));
	for (ll i = 0; i < N; i++)
	{
		ll temp = K - A[i];
		// cout << A[i]<<endl;
		if (temp >= 0)
		{
			auto it = upper_bound(B.begin(), B.end(), temp);
			// cout <<temp<<" "<<*it<<endl;
			// if(*it <= temp)
			ans = max(ans, i + 1L + (it - B.begin()));
			// else
			// {
			// 	ans = max(ans,i+1);
			// }
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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 (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

class UnionFind
{
private:
	vector<ll> p;
public:
	UnionFind(ll n){
		p.resize(n,-1);
	}
	ll find(ll x){
		if(p[x]==-1)return x;
		return find(p[x]);
	}
	void unite(ll x,ll y){
		x = find(x);
		y = find(y);
		if(x==y)return;
		p[y]=x;
	}
};



signed main(){
	ll n,q; cin>>n>>q;
	vl ans(0);
	UnionFind uf(n);
	rep(i,0,q){
		int com; cin>>com;
		ll x,y; cin>>x>>y;
		if(com==0){//unite
			uf.unite(x,y);
		}
		if(com==1){//find
			if(uf.find(x)==uf.find(y)){
				ans.push_back(1);
			}
			else{
				ans.push_back(0);
			}
		}
	}
	for(auto c:ans)cout<<c<<'\n';
	
	return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<vector<long>> data(N, vector<long> (26));
  char a;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 10; j++){
      cin >> a;
      data.at(i).at(a - 'a')++;
    }
  }
  sort(data.begin(), data.end());
  long flag, count = 1, ans = 0;
  for(int i = 0; i < N - 1; i++){
    flag = 1;
    for(int j = 0; j < 26; j++){
      if(data.at(i).at(j) != data.at(i + 1).at(j)){
        flag = 0;
        break;
      }
    }
    if(flag == 1)count++;
    else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 26496
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define 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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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 (b<a) { a=b; return 1; } return 0; }

int main(){
  int64_t A,B,N;
  cin>>A>>B>>N;
  
  int64_t X;
  if(N<B-1) X=N;
  else X=B-1;
  
  int64_t O=A*X/B;
  int64_t C=A*(X/B);
  cout<<O-C<<endl;
  
}

Measured memory_bytes: 3636
H,W,K = map(int,input().split())
B=[[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j,c in enumerate(input()):
        if c == "#":
            B[i][j] = 1

def getCnt(r,c):
    cnt = 0
    for i in r:
        for j in c:
            if B[i][j] == 1:
                cnt += 1
    return cnt

ans = 0
for y in range(2**H):
    r = []
    for i in range(H):
        if (y>>i) % 2 == 1:
            r.append(i)
    for x in range(2**W):
        c = []
        for j in range(W):
            if (x >> j) % 2 == 1:
                c.append(j)
        if getCnt(r,c) == K:
            ans += 1

print(ans)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int a, b;
    cin >> a >> b;

    int res;
    FOR(i, 1, 4) {
        if(!(a==i || b==i)) res = i;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    O = input()
    E = input()
    s = []
    for i in range(len(E)):
        s.append(O[i])
        s.append(E[i])
    if len(O) - len(E):
        s.append(O[-1])
    print(''.join(s))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
string s,p;

int main()
{
    ft
    int t,i,j,n,m,l=0,r=0;
    cin>>s;
    for(char c:s)
    {
        if(c=='A')
        {
            l=1;
        }
        else
        {
            r=1;
        }
    }
    if(l==1 && r==1)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}



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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u32 n;

	std::cin >> n;

	std::string s;
	std::cin >> s;

	if(n%2!=0)
	{
		std::cout << "No\n";
		return 0;
	}

	u32 half = n/2;

	for(u32 i=0; i<half; i++)
	{
		if(s[i] != s[i+half])
		{
			std::cout << "No\n";
			return 0;
		}
	}

	std::cout << "Yes\n";
	
	return 0;
}

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

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])

min_distance = [float("inf")]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

def Bellman_Ford():
    for _ in range(N):
        update = False
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = min_distance[s] + d # 最短距離を上書きする
                update = True
        if not update:
            flag = 1
            break

def Bellman_Ford2():
    for _ in range(N):
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -float("inf")
                if g == N-1:
                    break
        else:
            continue
        break

flag = 0
Bellman_Ford()

if flag == 1:
    ans = min_distance[N-1]
    print(max(-ans,0))
else:
    Bellman_Ford2()
    ans = min_distance[N-1]
    if ans == -float("inf"):
        print(-1)
    else:
        print(max(-ans,0))

#print(min_distance)


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int walk, angle;
	double x = 0, y = 0;
	double rad = 90 * (M_PI / 180.0);
	double theta = 90;
	while(scanf("%d,%d", &walk, &angle), walk || angle) {
		y += walk * sin(rad);
		x += walk * cos(rad);
		theta = theta - angle;
		rad = theta * (M_PI / 180.0); 
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 3428
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <bitset>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string a[]={
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111"
};
int main(){
	int n;
	while(cin>>n){
		string pos="0000000";
		if(n==-1)break;
		for(int i =0;i <n;i++){
			int x;
			cin>>x;
			string tmp =a[x];
			string str1="";
			for(int j =0;j <tmp.length();j++){
				if(pos[j]==tmp[j]){
					str1 +="0";
				}else{
					str1 +="1";
				}
			}
			cout <<str1<<endl;
			pos =a[x];
		}
	}
	return 0;
}

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

struct node {
	int key;
	node *p, *l, *r;
};

node *root, *NIL;

void insert(int k)
{
	node* y = NIL;
	node* x = root;
	node* z;

	z = (node*)malloc(sizeof(node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}

	z->p = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) y->l = z;
		else y->r = z;
	}
}

node* find(node* x, int k)
{
	while (x != NIL && k != x->key)
	{
		if (k < x->key) x = x->l;
		else x = x->r;
	}

	return x;
}

node* getMinimam(node* z)
{
	while (z->l != NIL)
	{
		z = z->l;
	}

	return z;
}

node* getSuccessor(node* z)
{
	if (z->r != NIL) return getMinimam(z->r);
	
	node* y = z->p;
	while (y->p != NIL && z == y->r)
	{
		z = y;
		y = y->p;
	}
	return y;
}

void deleteNode(node* z)
{
	node* y, *x;
	if (z->l == NIL || z->r == NIL) y = z;
	else y = getSuccessor(z);

	if (y->l != NIL) x = y->l;
	else x = y->r;
	
	if(x != NIL) x->p = y->p;

	if (y->p == NIL) root = x;
	else if (y->p->l == y) y->p->l = x;
	else if (y->p->r == y) y->p->r = x;

	if (y != z) z->key = y->key;

	free(y);

	return;
}

void inorder(node *n)
{
	if (n == NIL) return;

	inorder(n->l);
	cout << " " <<  n->key;
	inorder(n->r);

	return;
}

void preorder(node *n)
{
	if (n == NIL) return;

	cout << " " << n->key;
	preorder(n->l);
	preorder(n->r);

	return;
}

int main(void)
{
	int N, k;
	string s;
	list<node> t;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> s;
		if (s == "insert"){
			cin >> k;
			insert(k);
		}
		else if (s == "print") {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (s == "find") {
			cin >> k;
			node *x = find(root, k);
			if (x != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (s == "delete") {
			cin >> k;
			deleteNode(find(root, k));
		}
	}
	
	return 0;
}


Measured memory_bytes: 21920
N,M,K=gets.split.map(&:to_i)
MOD=10**9+7

def modpow(a,b,m)
  return b==0 ? 1 : b%2==1 ? (modpow(a,b-1,m)*a)%m : modpow(a**2%m,b/2,m) 
end
def fact(n,m)
  return (1..n).inject(1){|a,b| a*b%m}
end
def inv(n,m)
  return modpow(n,m-2,m)
end
def comb(n,r,m)
  return fact(n,m)*inv(fact(r,m),m)*inv(fact(n-r,m),m)%m
end

puts M*N*(M+N)*(M*N-1)*comb(N*M-2,K-2,MOD)/6%MOD


Measured memory_bytes: 1788
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int a[110];
  rep(i, m) cin >> a[i];
  int mas[110] = {};
  rep(i, m) mas[a[i]] += 1;
  int cost1 = 0, cost2 = 0;

  for(int i=x+1; i<n; ++i) {
    if(mas[i]==1) {
      cost1 += 1;
    }
  }

  for(int i=x-1; i>0; --i) {
    if(mas[i]==1) {
      cost2 += 1;
    }
  }

  cout << min(cost1, cost2) << endl;

  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool dp[80][80][6401];

void solve(long long H, long long W, std::vector<std::vector<long long>> A, std::vector<std::vector<long long>> B){
    dp[0][0][abs(A[0][0]-B[0][0])] = true;
    REP(i, H) {
        REP(j, W) {
            REP(k, 6401) {
                if(dp[i][j][k]){
                    if(i+1 != H) {
                        dp[i+1][j][abs(k-abs(A[i+1][j]-B[i+1][j]))] = true;
                        if(abs(k+abs(A[i+1][j]-B[i+1][j])) <= 6400) {
                            dp[i+1][j][abs(k+abs(A[i+1][j]-B[i+1][j]))] = true;
                        }
                    }
                    if(j+1 != W) {
                        dp[i][j+1][abs(k-abs(A[i][j+1]-B[i][j+1]))] = true;
                        if(abs(k+abs(A[i][j+1]-B[i][j+1])) <= 6400) {
                            dp[i][j+1][abs(k+abs(A[i][j+1]-B[i][j+1]))] = true;
                        }
                    }
                }
            }
        }
    }

    REP(i, 81) {
        if(dp[H-1][W-1][i]) {
            cout << i << endl;
            break;
        }
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    std::vector<std::vector<long long>> B(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&B[i][j]);
        }
    }
    solve(H, W, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 40192
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using ld = long double;
static const double pi = 3.141592653589793;

ld mul(const P &p, ld arg) {
    ld x, y;
    tie(x, y) = p;
    return cos(arg) * x + sin(arg) * y;
}

int main() {
    ll N;
    cin >> N;
    vector<P> v(N);
    for (auto &p : v) cin >> p.first >> p.second;
    vector<ll> cnt(N);
    ld split = 1e5;
    for (ll i = 0; i < (ll)split; i++) {
        ld arg = 2 * pi / split * i;
        ld val = mul(v[0], arg);
        ld idx = 0;
        for (ll j = 1; j < N; j++) {
            ld tmp = mul(v[j], arg);
            if (tmp > val) {
                val = tmp;
                idx = j;
            }
        }
        cnt[idx]++;
    }
    for (ll v : cnt) printf("%.20Lf\n", v / split);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

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

int main() {
    
    ll n,k;
    cin>>n>>k;
    n=n%k;
    if(k-n<n)n=k-n;
    fin(n);


}



Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	if (none_of(a.begin(), a.end(), [](auto e) {return e == 1; })) {
		cout << -1 << "\n";
		return 0;
	}
	int cnt = 1;
	for (int i = 0; i < N; i++) if (cnt == a[i]) cnt++;

	cout << N - (cnt - 1) << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n,kd;
    cin>>n>>kd;
    int k[30],a[n][30];
    int b[n];
    rep(i,30){
        k[29-i]=(kd&1);
        kd/=2;
    }
    rep(i,n){
        int s;
        cin>>s>>b[i];
        rep(j,30){
            a[i][29-j]=(s&1);
            s/=2;
        }
    }
    ll ans=-1;
    rep(i,30){
        if(k[i]==0)continue;
        int s[30];
        rep(j,i){
            s[j]=k[j];
        }
        s[i]=0;
        for(int j=i+1;j<30;++j){
            s[j]=1;
        }
        ll mx=0;
        rep(j,n){
            bool flag=true;
            rep(l,30){
                if(s[l]==0&&a[j][l]==1){
                    flag=false;
                    break;
                }
            }
            if(flag)mx+=b[j];
        }
        ans=max(mx,ans);
    }
    ll mx=0;
    rep(j,n){
        bool flag=true;
        rep(l,30){
            if(k[l]==0&&a[j][l]==1){
                flag=false;
                break;
            }
        }
        if(flag)mx+=b[j];
    }
    ans=max(mx,ans);
    cout<<ans<<endl;
}


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

int main() {
  int x,y;
  cin >> x >> y;
  for(int i=0;i<x+1;i++){
    for(int j=0;j<x+1;j++){
      if(i*2+j*4==y&&i+j==x){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}


Measured memory_bytes: 3552
from collections import defaultdict

n, a = map(int, input().split())
x = list(map(int, input().split()))
y = [xi - a for xi in x]

# 解説AC
dp = [defaultdict(int) for i in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in dp[i]:
        dp[i + 1][j + y[i]] += dp[i][j]
        dp[i + 1][j] += dp[i][j]
print(dp[n][0] - 1)


Measured memory_bytes: 74328
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
struct T{ int to, nxt, v; } way[maxn << 1];
int h[maxn], num;
inline void link(int x,int y) {
	way[++num] = {y,h[x],1}, h[x] = num;
	way[++num] = {x,h[y],2}, h[y] = num;
}
int n, m;
int vis[maxn], c[maxn], ct[3], flag = 0, edge = 0;
inline void dfs0(int x) {
	vis[x] = 1; ++ ct[c[x]];
	for(int i = h[x];i;i = way[i].nxt) {
		++ edge;
		int to = way[i].to;
		int v = (c[x] + way[i].v) % 3;
		if(c[to] != -1 && c[to] != v) flag = 1;
		c[to] = v;
		if(!vis[to]) dfs0(to);
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 0, x, y;i < m;++i) {
		cin >> x >> y, link(x, y);
	}
	rep(i, 1, n) c[i] = -1;
	ll ans = 0;
	rep(i, 1, n) if(!vis[i]) {
		c[i] = 0, dfs0(i);
		if(flag) {
			ans += ll(ct[0] + ct[1] + ct[2]) * (ct[0] + ct[1] + ct[2]);
		} else if(!ct[2] || !ct[1]) {
			ans += edge / 2;
		} else {
			ans += (ll) ct[0] * ct[1] + (ll) ct[1] * ct[2] + (ll) ct[2] * ct[0];
		}
		edge = flag = ct[0] = ct[1] = ct[2] = 0;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 7424
S = input()
T = input()
ans = float('inf')
for i in range(len(S)):
    tmp_ans = 0
    for j in range(len(T)):
        if j + i >= len(S):
            break
        if S[i + j] != T[j]:
            tmp_ans += 1
    else:
        ans = min(ans, tmp_ans)
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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 (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    string s,t;cin>>s>>t;
    string res;
    int tmp=-1;
    for(int i=0;i+t.size()-1<s.size();i++){
        bool jud=true;
        rep(j,t.size()){
            if(s[i+j]!=t[j]&&s[i+j]!='?'){
                jud=false;
                break;
            }
        }
        if(jud)tmp=i;
    }
    if(tmp==-1){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }else{
        rep(j,t.size()){
            s[tmp+j]=t[j];
        }
        rep(i,s.size()){
            if(s[i]=='?')s[i]='a';
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 256
mod = 10**9+7
def prod(A):
    r = 1
    for a in A:
        r *= abs(a)
        r %= mod
    return r

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), key=abs, reverse=True)

Ak = A[:K]
m = len([a for a in Ak if a<0])

if m%2==0:
    print(prod(Ak))
    exit()

r_p = [a for a in A[K:] if a>=0]
r_n = [a for a in A[K:] if a<=0]
a_p = [a for a in Ak    if a> 0]
a_n_min = max([a for a in Ak if a< 0])

ans1 = ans2 = None
if r_p:
    v1 = abs(a_n_min)
    w1 = max(r_p)
    ans1 = prod(Ak)*pow(v1, mod-2, mod) * w1 % mod
    
if a_p and r_n:
    v2 = min(a_p)
    w2 = abs(min(r_n))
    ans2 = prod(Ak)*pow(v2, mod-2, mod) * w2 % mod
    
if ans1 and ans2:
    print(ans1 if w1*v2>=w2*v1 else ans2)
    exit()

if ans1:
    print(ans1)
    exit()

if ans2:
    print(ans2)
    exit()

print((-prod(A[::-1][:K]))%mod)


Measured memory_bytes: 31868
import * as fs from "fs"

function solve() {
    const [S, T] = (require('fs').readFileSync("/dev/stdin", "utf8") as string).split("\n");
    let cnt = 0
    for (let i = 0; i < 3; i++) {
      if (S[i] === T[i]) {
        cnt += 1;
      }
    }
    console.log(cnt);
}

solve();


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

#define MAX (int)1e5 + 5
using namespace std;
vector<int> graph[MAX];
int dist[MAX];
int indegree[MAX];
bool visited[MAX];

void dfs(int a)
{
	visited[a] = true;
	for (int b : graph[a])
	{
		dist[b] = max(dist[b],dist[a] + 1); // calculate the path from a to b
		indegree[b]--;
		if (indegree[b] == 0)
			dfs(b);	
	}		
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int m,n;
	cin >> n >> m; 	
	for (int i = 0 ; i < m ; i++)
	{
		int u,v;
		cin >> u >> v;
		graph[u].push_back(v);
		indegree[v]++;
	}
	for (int i = 0 ; i <= n ; i++)
	{
		if (!visited[i] && indegree[i] == 0) dfs(i);
	}
	int res = INT_MIN;
	for (int i = 0 ; i <= n ; i++)
	{
		res = max(res,dist[i]);
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 9728
package main

import (
	"fmt"
)

func main() {
	for {
		var a, b int
		var op string
		if _, err := fmt.Scan(&a, &op, &b); err != nil {
			panic(err)
		}
		if op == "?" {
			break
		}

		switch op {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		case "/":
			fmt.Println(a / b)
		}
	}
}



Measured memory_bytes: 1132
// Problem : B - Choose Integers
// Contest : AtCoder - AtCoder Beginner Contest 060
// URL : https://atcoder.jp/contests/abc060/tasks/abc060_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, c, m;
	cin >> a >> b >>c;
	m = a;
	for(int i=0;i<b;i++){
	    a%=b;
	    if(a==c){
	        cout << "YES";
	        return 0;
	    }
	    a+=m;
	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
// review

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const ll INF = 1e15+10;

ll k;

ll f(ll n) {
  ll res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

double g(ll n) {
  return (double)n / f(n);
}

vector<ll> v;

void check(ll n) {
  double cur = g(n);
  while (!v.empty()) {
    ll prev = v[v.size() - 1];
    if (g(prev) > cur) {
      v.pop_back();
    } else {
      break;
    }
  }
  v.push_back(n);
}

void solve() {
  double minVal = INF;
  double tmp = 0;
  for (int i=1;i<100;i++) {
    check(i);
  }

  ll base = 1;
  while (base < 1e13) {
    for (int i=100;i<1000;i++) {
      ll val = i * base + base - 1;
      check(val);
    }
    base *= 10;
  }
  for (int i=0;i<k;i++) {
    cout << v[i] << endl;
  }
}

int main() {
  cin >> k;
  solve();
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int result = 1500;
  for(int i = 0; i < S.length()+1-T.length(); i++){
    string tmp = S.substr(i, T.length());
    int tmpint = 0;
    for(int i = 0; i < T.length(); i++){
      if(tmp[i] != T[i]){
        tmpint ++;
      }
    }
    if(tmpint < result){
      result = tmpint;
    }
  }
  cout << result << endl;
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	//~ int a1=1,b1=0,a2=1,b2=0;
	//~ rep(i,100){
		//~ if(i%2==0){
			//~ a1-=a2;
			//~ b1-=b2;
		//~ }
		//~ else{
			//~ a2+=a1;
			//~ b2+=b1;
		//~ }
		//~ cout<<i<<": "<<a1<<' '<<a2<<' '<<b1<<' '<<b2<<endl;
	//~ }
	ll n,a,b;cin>>n>>a>>b;
	n%=12;
	rep(i,n){
		if(i%2==0){
			a-=b;
		}
		else b+=a;
	}
	cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int a[101];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int ans = 0;
	int renzoku = 1;
	int nowc = a[0];
	for(int i = 1; i < n; i++){
		if(a[i] == nowc){
			renzoku++;
		} else {
			ans += renzoku / 2;
			renzoku = 1;
			nowc = a[i];
		}
		// cout << nowc << " " << renzoku << endl;
	}
	ans += renzoku / 2;
	cout << ans << endl;
}

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

int main() {
int n;
  int ans=0;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<n;i+=2){
  if(vec.at(i)%2==1){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632