akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MAX_P = 200001;
const long long MOD = 1000000007;
typedef long long ll;

// 入力はすべて正とする
// 素数判定O(√n)
bool is_prime(long long n) {
	for (long long i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return n != 1; // 1の場合は例外
}
// 約数の列挙O(√n)
vector<long long> divisor(long long n) {
	vector<long long> res;
	for (long long i = 1; i * i <= n; i++) {
  	if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) res.push_back(n / i);
		}
	}
	return res;
}
// 素因数分解O(√n)
map<long long, long long> prime_factor(long long n) {
	map<long long, long long> res;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

long long mod_inverse(long long a, long long m) {
	long long x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

long long fact[MAX_P+1];
// n! mod pのテーブルを作る O(p)
void mod_fact(long long n, long long m) {
	fact[0] = 1;
	for (long long i = 1; i <= n; i++) fact[i] = fact[i-1]*i%m;
}

// n!=a p^e としたときのa mod pを求める。O(log_p n)
long long mod_fact(long long n, long long p, long long& e) {
	e = 0;
	if (n == 0) return 1;
	// pの倍数の部分を計算
	long long res = mod_fact(n / p, p, e);
	e += n / p;
	// (p-1)!≡-1なので(p-1)!^(n/p)はn/pの偶奇だけで計算できる
	if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
	return res * fact[n % p] % p;
}

// nCk mod pを求める。O(log_p n)
long long mod_comb(long long n, long long k, long long p) {
	if (n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
	//if (a1 * mod_inverse(a2 * a3 % p, p) % p == 0) printf("%lld, %lld, %lld,%lld, %lld, %lld\n",n, p, e1,a1, a2, a3);
	if (e1 > e2 + e3) return 0;
	return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

pair<long long, long long> crt(const vector<long long> &a, const vector<long long> &m) {
	long long r = 0, M = 1;
	for (int i = 0; i < (int)a.size(); ++i) {
		if (a[i] == -1) continue;
		long long p, q;
		long long d = extgcd(M, m[i], p, q);
		if ((a[i] - r) % d != 0) return make_pair(-1, -1);;
		long long tmp = (a[i] - r) / d * p % (m[i]/d);
		r += M * tmp;
		M *= m[i]/d;
	}
	return make_pair((r % M + M) % M, M);
}

int main(){
	ll N,M,D;
	scanf("%lld",&N);
	scanf("%lld",&M);
	scanf("%lld",&D);
	vector<ll> A(M);
	for (int i = 0; i < M; i++) {
		scanf("%lld",&A[i]);
	}
	vector< vector<ll> > R;
	R = vector< vector<ll> >(D, vector<ll>(M, 0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < M; j++) {
			scanf("%lld",&R[i][j]);
		}
	}

	ll res = N;
	for (int i = 0; i < D; i++) {
		pair<ll, ll> c = crt(R[i], A);
		if (c.first > res || c.first == -1) {
			res = -1;
			break;
		}
		res = c.first+(res-c.first)/c.second*c.second;
	}
	cout << res << endl;

	return 0;
}



Measured memory_bytes: 3260
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<double> p(N);

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

    vector<vector<double>> dp(N, vector<double>(N + 1, 0));
    dp[0][0] = 1.0 - p[0];
    dp[0][1] = p[0];

    for (int i = 1; i < N; i++) {
        for (int j = 0; j < i + 2; j++) {
            if (j > 0 && j < i + 1) {
                dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1.0 - p[i]);
            } else if (j == 0) {
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
            } else if (j == i + 1) {
                dp[i][j] = dp[i - 1][j - 1.0] * p[i];
            }
        }
    }

    double ans = 0.0;
    for (int j = N / 2 + 1; j < N + 1; j++) {
        ans += dp[N - 1][j];
    }

    cout << fixed;
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x,sum=0;
    scanf("%d %d %d",&n,&d,&x);
     vector<int> box(n);
    for(int i=0;i<n;i++)
        cin>>box.at(i); 
    
    for(int i=0;i<n;i++){
        int j=1;    
        while(box[i]*j+1<=d){
            sum++;  
            j++;
        }
    }
    printf("%d\n",x+n+sum);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        
        
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            var g = new Graph();
            List<List<int>> G = new List<List<int>>();
            bool[] seen = new bool[N];
            g.Gin(G, N);
            g.Sfalse(seen);

            int[,] node = new int[M, 2];
            for(var i = 0; i < M; i++)
            {
                var cin = Console.ReadLine().Split().Select(int.Parse).ToArray();
                node[i, 0] = cin[0] - 1;
                node[i, 1] = cin[1] - 1;
                G[node[i,0]].Add(node[i,1]);
                G[node[i,1]].Add(node[i,0]);
            }

            long ans = 0;

            for(var i = 0; i < M; i++)
            {
                G[node[i, 0]].Remove(node[i, 1]);
                G[node[i, 1]].Remove(node[i, 0]);
                seen[0] = true;
                g.Dfs(G, seen, 0);
                if (!g.AllUnion(seen)) { ans++; }

                g.Sfalse(seen);
                G[node[i, 0]].Add(node[i, 1]);
                G[node[i, 1]].Add(node[i, 0]);
            }

            Console.WriteLine(ans);

            

            //Console.Out.Flush();

        }

        
    }

    public class Calculation
    {

    }

    public class Graph
    {
        public void Dfs(List<List<int>> graph, bool[] seen, int v)
        {
            seen[v] = true;
            //初めて訪れたタイミングでここの処理

            foreach (var next in graph[v])
            {
                if (seen[next] == true) { continue; }
                Dfs(graph, seen, next);
            }
            //行き先がない状態になったらこの部分の処理

        }

        public void Gin(List<List<int>> graph,int size)
        {
            for(var i = 0; i < size; i++)
            {
                graph.Add(new List<int>());
                
            }
        }

        public void Sfalse(bool[] seen)
        {
            for(var i = 0; i < seen.Length; i++)
            {
                seen[i] = false;
            }
        }

        public bool AllUnion(bool[] seen)
        {
            for(var i = 0; i < seen.Length; i++)
            {
                if (!seen[i])
                {
                    return false;
                }
            }
            return true;
        }
    }
}



Measured memory_bytes: 13280
import sys
import numpy as np

# N 参加した人数
n = int(input())

# ai 各参加者のレート
rate = list(map(int, input().split()))

# 各レートによる人数
people = np.zeros(8)
# 3200以上の好きな色を選べる人数
free = 0

for r in rate:
    # レートによって人数を求める
    if r < 400:
        people[0] += 1
    elif r < 800:
        people[1] += 1
    elif r < 1200:
        people[2] += 1
    elif r < 1600:
        people[3] += 1
    elif r < 2000:
        people[4] += 1
    elif r < 2400:
        people[5] += 1
    elif r < 2800:
        people[6] += 1
    elif r < 3200:
        people[7] += 1
    else:
        free += 1

if people[people > 0].size > 0:
    # 最小は色の数
    min_color = people[people > 0].size
    # 最大は、最小 + 選べる人数
    max_col = min_color + free
else:
    # 高得点者しかいない場合、最小は 1
    min_color = 1
    # 最大は高得点者
    max_col = free

print(min_color, max_col)

Measured memory_bytes: 12508
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int

int main(){

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

    int a;
    cin>>a;
    int arr[a];

    ull sum = 0;

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

    for(int i = 0;i<a;i++){
        for(int j = i+1;j<a;j++){
            sum = sum + arr[i]*arr[j];
        }
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
import collections
import math

def combinations_count(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N = int(input())
s = [""]*N
for i in range(N):
    s[i] = ','.join(sorted(input()))

c = collections.Counter(s)
ans = 0
for value in c.values():
    if(value == 1):
        continue
    ans += combinations_count(value, 2)
    
print(ans)

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

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

    if ((a + b) % 2 != 0)
    {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    cout << (a + b) / 2 << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;

    rep(a, 0, 2) rep(b, 0, 2) rep(c, 0, 2) {
        int sm = 0;

        sm += S[0] - '0';

        if (a == 0) sm += S[1] - '0';
        else sm -= S[1] - '0';

        if (b == 0) sm += S[2] - '0';
        else sm -= S[2] - '0';

        if (c == 0) sm += S[3] - '0';
        else sm -= S[3] - '0';

        if (sm == 7) {
            cout << S[0];
            if (a == 0) cout << "+";
            else cout << "-";
            cout << S[1];
            if (b == 0) cout << "+";
            else cout << "-";
            cout << S[2];
            if (c == 0) cout << "+";
            else cout << "-";
            cout << S[3] << "=7" <<endl;
            return;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tsolve int t;cin>>t;while(t--)  solve();
#define f(i,n)   for(int i=0;i<n;i++)
#define ff first
#define all(a) a.begin(),a.end()
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
int main(){
    int n,t,f;
    cin>>n>>t>>f;
    vector<double> a(n);
    f(i,n)  cin>>a[i];
    vector<double> b(n);
    f(i,n)  b[i]=t-a[i]*0.006;
    f(i,n)  b[i]=abs(b[i]-f);
    cout<<(min_element(all(b))-b.begin())+1;
    return 0;
}

Measured memory_bytes: 256
import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def count(s: String, t: String) = {
    (0 to s.length - t.length).map(n => s.drop(n)).filter(_.startsWith(t)).size
  }
  def main(args: Array[String]) {
    while(sc.hasNext) {
      val s = sc.next
      println(count(s, "JOI"))
      println(count(s, "IOI"))
    }
  }
}

Measured memory_bytes: 149904
#include<stdio.h>
#define MAX 100

int swap(int *x,int *y){
  int z=*x;
  if(*x==*y)return 0;//同じだったら０
  *x=*y;
  *y=z;
  return 1;//違ったら１
}

// N個の要素を含む0-オリジンの配列A
//Aの数を並べ替えて入れ直す
//    / 交換が行われた回数
int selectionSort(int *A,int n){ 
  int i;
  int j;
  int minj;
  int count=0;
  
  for (i=0;i<=n-1;i++){
    minj = i;
    
    for (j=i;j<=n-1;j++){
      if (A[j] < A[minj]) minj=j;
    }
    if(swap(&A[i], &A[minj]))count++;
  }
  return count;
}


int main(){
  int i;
  int n;
  int A[MAX];
  int count=0;
 
  scanf("%d",&n);//Input
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  count=selectionSort(A,n);


  for(i=0;i<n;i++){//OUTPUT
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);

    
  return 0;
}
//
//3
//1 3 4を昇順に



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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  vector<int> w(n+1), b(n+1);
  w.at(n) = 0; b.at(0) = 0;
  for (int i = n-1; i >= 0; i--){
    w.at(i) = w.at(i+1);
    if (s.at(i) == '.') w.at(i)++;
  }
  for (int i = 0; i < n; i++){
    b.at(i+1) = b.at(i);
    if (s.at(i) == '#') b.at(i+1)++;
  }
  int ans = 200010;
  for (int i = 0; i <= n; i++){
    ans = min(ans, b.at(i)+w.at(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2180
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let N = +cin.shift();
    let A = cin.map(x => +x);
    let node = Array(N + 1);
    node[0] = 1;
    for (let d = 0; d < N; d++) {
        node[d + 1] = (node[d] - A[d]) * 2;
        if (node[d + 1] < A[d + 1]) {
            console.log(-1);
            return;
        }
    }
    //console.log(sum(node));
    if (node[N] < A[N]) {
        console.log(-1);
    } else if (node[N] == A[N]) {
        console.log(sum(node));
    } else {
        // node[d] が多すぎた場合。枝を逆に減らしていく必要がある。
        let nodemax = Array(N + 1);
        nodemax[N] = A[N];
        for (let d = N; d > 0; d--) {
            //console.log({ d, A, node, nodemax}, sum(node));
            if (nodemax[d] < node[d]) {
                node[d] = nodemax[d];
                nodemax[d - 1] = node[d] + A[d - 1];
            }
        }
        if (nodemax[0] < node[0]) {
            node[0] = nodemax[0];
        }
        console.log(sum(node));
    }
}
var sum = function (arr) {
    var sum = 0n;
    arr.forEach(function (elm) {
        sum += BigInt(elm);
    });
    return sum.toString();
};
main();



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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

/***** MAIN *****/
signed main() {
  int n, ans = 0;
  scanf("%d", &n);
  int order[n], performance[n], additional[n-1];
  REP(i, n) {
    scanf("%d", &order[i]);
  }
  REP(i, n) {
    scanf("%d", &performance[i]);
  }
  REP(i, n-1) {
    scanf("%d", &additional[i]);
  }
  ans += performance[order[0]-1];
  REPS(i, 1, n) {
    ans += performance[order[i]-1];
    if(order[i-1]+1 == order[i]) {
      ans += additional[order[i]-2];
    }
  }

  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];
    rep(i,0,N) cin >> C[i];

    sort(all(A));
    sort(all(B));
    sort(all(C));

    ll ans = 0LL;

    rep(i,0,N){
        ans += 1LL * (lower_bound(all(A),B[i]) - A.begin()) * (C.end() - upper_bound(all(C),B[i]));
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2560
# 0:表 1:裏
# 1の数を計算する
# ある行に操作が奇数回適用されると 1(M=1) or 0(1..1)0(M>=2)
## 1の個数num_of_one=1 or M-2
# ある行に操作が偶数回適用されると 0..0
## 1の個数は0
# 各行のパターンは (奇数パターン)(N=1) or
# (偶数パターン)(奇数パターン..奇数パターン)(偶数パターン)(N>=2)
# 1の個数の合計(答え)は num_of_one (N=1) or num_of_one*(N-2)

N,M=map(int,input().split())

if M==1:
    num_of_one=1
else:
    num_of_one=M-2
if N==1:
    ans=num_of_one
else:
    ans=num_of_one*(N-2)
print(ans)

Measured memory_bytes: 2940
s = list(input())

a_idx = 0
z_idx = len(s) - 1
for i in range(len(s)):
  if s[i] == "A":
    a_idx = i
    break

for i in range(len(s)):
  if s[len(s) -1 -i] == "Z":
    z_idx = len(s) -1 -i
    break  

print(z_idx - a_idx + 1)

Measured memory_bytes: 10396
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	x := make([]int, N)
	x[0] = a[0]
	for i := 1; i < N; i++ {
		x[i] = GCD(x[i-1], a[i])
	}

	y := make([]int, N)
	y[N-1] = a[N-1]
	for i := N - 2; i >= 0; i-- {
		y[i] = GCD(y[i+1], a[i])
	}
	// out(x)
	// out(y)

	ans := max(x[N-2], y[1])
	for i := 1; i < N-1; i++ {
		g := GCD(x[i-1], y[i+1])
		ans = max(ans, g)
	}
	out(ans)
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double t, a;
  int h;
  double mn = INF;
  int argmin;
  cin >> n;
  cin >> t >> a;
  REP(i,n){
      cin >> h;
      if (abs(t - h * 0.006 - a)< mn){
          mn = abs(t - h * 0.006 - a);
          argmin = i;
      }

  }
  cout << argmin+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int N;
    ll A[100000];
    cin>>N;
    int minus;
    ll minus_max=-1000000001,plus_min=1000000001;
    ll ans=0;
    rep(i,N) {
        cin>>A[i];
        if(A[i]<0) {
            minus++;
            minus_max=max(minus_max,A[i]);
            ans-=A[i];
        }else{
            plus_min=min(plus_min,A[i]);
            ans+=A[i];
        }
    }
    if(minus%2==0) cout<<ans<<endl;
    else{
        ans=max(ans+2*minus_max,ans-2*plus_min);
        cout<<ans<<endl;
    }



    return 0;
}

Measured memory_bytes: 1024
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;
/*ll arr[mxn][4];
ll dp[mxn][4],n,w;
ll solve(int i,int prev)
{
  if(i==n)
    return 0;
  if(dp[i][prev]!=-1)
    return dp[i][prev];
  ll ans=0,j;
  fr(j,1,4)
  {
    if(prev!=j)
      ans=max(ans,solve(i+1,j)+arr[i][j]);
  }
  return dp[i][prev]=ans;
}*/
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
    while(t--){
      ll i,j,n,w;
      cin>>n>>w;
      ll val[n],wieght[n];
      fr(i,0,n)
      {
        cin>>wieght[i]>>val[i];
      }
      ll dp[n+1][w+1];
      ms(dp,0);
      fr(i,1,n+1)
      {
        fr(j,1,w+1)
        {
          if(j>=wieght[i-1])
          dp[i][j]=max(dp[i-1][j],dp[i-1][j-wieght[i-1]]+val[i-1]);
        else dp[i][j]=dp[i-1][j];
        }
      }
     /* fr(i,0,n+1)
      {
        fr(j,0,w+1)
        cout<<dp[i][j]<<" ";
        cout<<"\n";
      }*/
      cout<<dp[n][w];
      
       
    }
  return 0;
  }



Measured memory_bytes: 79232
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]))
answer = dp[-1]
print(answer)

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define N 100005
#define ll long long
#define pii pair<ll,int>
#define mp make_pair
using namespace std;

ll n,size[N];
int e[N][2];
pii a[N];

inline ll read()
{
	ll ans=0,f=1;char c=getchar();
	while(c>'9'||c<'0') {if(c=='-') f=-1ll;c=getchar();}
	while(c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans*f;
}

int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=mp(read(),i),size[i]=1;
	sort(a+1,a+1+n);
	for(int i=n;i>1;i--)
	{
		ll cur=a[i].first-n+2*size[i];
		int l=1,r=i-1;
		while(l<r)
		{
			int mid=l+r>>1;
			if(a[mid].first<cur) l=mid+1;
			else r=mid;
		}
		if(a[l].first!=cur) return puts("-1"),0;
		e[i][0]=a[i].second;
		e[i][1]=a[l].second;
		size[l]+=size[i];
	}
	for(int i=2;i<=n;++i) a[1].first-=size[i];
	if(a[1].first) return puts("-1"),0;
	for(int i=2;i<=n;++i) printf("%d %d\n",e[i][0],e[i][1]);
}


Measured memory_bytes: 4480
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)

#N,*A = map(int,read().split())
N = int(input())
A = list(map(int,input().split()))

#現在作ってる数列の種類を記録
# 単調増加：1
# 単調減少 ：-1
# 初期値:0
State = 0

#答え入れる
res = 1

for i in range(1,N):
    
    #A[i]はA[i-1]と比べたときの大小を記録

    #X に現在の状態を記録
    # 増加：1
    # 減少 ：-1
    # 同じ値:0
    if A[i] > A[i-1]: #大きくなった時
        X = 1 
    elif A[i] == A[i-1]: #等しい時
        X = 0
    else :# それ以外(小さくなった時)
        X = -1

    #現在の状態と作っている数列の状態が同じとき
    if X == State:
        continue
    
    #配列の種類が0の時(どちらにもなりえる)
    if  State == 0: 
        State = X #Stateが決定されるため、更新

    #現在の状態と作っている数列の状態が違い、現在の状態が0出ないとき
    if X != State  and  X != 0: 
        res += 1 
        State = 0 #数列を初期化

print(res)




Measured memory_bytes: 14484
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod = 1e9+7;
const int N = 2e5+4;

 
ll fac[N],infac[N];
 
ll me(ll a,ll b)
{
	ll res=1;
 
	while(b)
	{
		if(b&1)
		res=(res*a)%mod;
 
		a=(a*a)%mod;
 
		b>>=1;
	}
 
	return res;
}
 
ll mi(ll n)
{
	return me(n,mod-2);
}
 
void factorial()
{
	fac[0]=1;
 
	for(ll i=1;i<N;i++)
	fac[i]=(i*fac[i-1])%mod;
 
	//modular inverse factorial array in O(logn+n)=O(n) time
 
	infac[N-1]=mi(fac[N-1]); //O(logn)
 
	for(ll i=N-1;i>0;i--)
	infac[i-1]=(i*infac[i])%mod;
}
 
ll ncr(int n,int r)
{
	if(n<r)
	return 0;
 
	ll res=fac[n];
 
	res=(res*infac[r])%mod;
 
	res=(res*infac[n-r])%mod;
 
	return res;
}
 
int main()
{
	factorial();

	int n,k; scn(n); scn(k); k = min(k,n-1);

	ll ans = 0;

	for(int zeroes = 0;zeroes <= k;zeroes++)
	{
		ll here = ncr(n,zeroes);

		int balls = n, boxes = n-zeroes;

		//no. of positive solutions
		ll temp = ncr(balls-1,boxes-1);

		here = (here*temp)%mod;

		ans = (ans+here)%mod;
	}

	lpri(ans);

	return 0;
}

Measured memory_bytes: 6952
#include<iostream>
#include<algorithm>
using namespace std;
struct data{
    string a;
    int ans;
}x[102];
int n,m,w;
string s[102],t[102];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        int j;
        for(j=w;j>0;j--)
            if(s[i]==x[j].a)
            {
                x[j].ans++;
                break;
            }
        if(!j) w++,x[w].a=s[i],x[w].ans++;
    }
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>t[i];
        for(int j=w;j>0;j--)
            if(t[i]==x[j].a)
            {
                x[j].ans--;
                break;
            }
    }
    int Ans=0;
    for(int i=1;i<=w;i++)
        Ans=max(Ans,x[i].ans);
    cout<<Ans;
}

Measured memory_bytes: 256
N = gets.chomp.split("")

t = N.last
t = t.to_i
if (t==2) or (t==4) or (t==5) or (t==7) or (t==9)
  puts "hon"
elsif (t==0) or (t==1) or (t==6) or (t==8)
  puts "pon"
else 
  puts "bon"
end

Measured memory_bytes: 14376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long, long>
#define ff first
#define ss second
#define pb push_back


main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N; ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a, a+N, greater<ll>());
    ll ans = 0;
    if(N == 1){
        ans = 0;
    } else if(N == 2){
        ans = a[0];
    } else if(N == 3){
        ans = a[0] + a[1];
    } else{
        ans = a[0];
        for(int i = 2, j = 1, c = 0; i < N; i++, c = (c^1)){
            ans += a[j];
            if(c == 1) j++;
        }
    }
    cout << ans;
}


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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rreps(i, n) for (int (i) = (n); (i) > 0; (i)--)
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.141592653589793238462643383279;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} init;

int N, A[110000], l[110000], r[110000];
signed main() {
    cin >> N;
    reps(i, N) { cin >> A[i]; }
    reps(i, N) { l[i] = gcd(l[i - 1], A[i]); }
    rreps(i, N) { r[i] = gcd(r[i + 1], A[i]); }
    int ans = 0;
    reps(i, N) { chmax(ans, gcd(l[i - 1], r[i + 1])); }
    cout << ans << endl;
}

Measured memory_bytes: 2560
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

ll n, m;
ll a[222222];
bool verify(ll x) { // can I have length x ?
	ll cuts = 0;
	for ( int k = 0; k < n; k++ ) {
		cuts += a[k] / x;
		if (a[k] % x == 0)
			cuts--;
	}
	return cuts <= m;
}

int main(){
	FASTIO;
	cin >> n >> m;
	parseArray(a, n);
	ll l = 1, h = 1e10, mid = 0;
	ll ans = h;
	while (l <= h) {
		mid = (l + h) / 2;
		if (verify(mid))
			ans = mid, h = mid - 1;
		else
			l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5104
class Dice:
    def __init__(self,list):
        self.list = []
        for i in range(6):
            self.list.append(list[i])

    def rotate(self,dir):
        if dir == "N":
            self.list[0], self.list[1], self.list[5], self.list[4] = self.list[1], self.list[5], self.list[4], self.list[0]
        elif dir == "S":
            self.list[0], self.list[4], self.list[5], self.list[1] = self.list[4], self.list[5], self.list[1], self.list[0]
        elif dir == "W":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[2], self.list[0], self.list[3], self.list[5]
        elif dir == "E":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[3], self.list[5], self.list[2], self.list[0]
        elif dir == "H":
            self.list[1], self.list[2], self.list[4], self.list[3] = self.list[2], self.list[4], self.list[3], self.list[1]
        elif dir =="V":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[3], self.list[5], self.list[2], self.list[0]
        else:
            pass

    def show(self):
        print("D:{}".format(repr(self.list)))

    def isface(self,f):
        if f in self.list:
            return True
        else:
            return False

    def isSameface(self,b):
        for i in range(len(self.list)):
            if self.list[i] != b.list[i]:
                return False
        return True

    def isSame(self,b):
        
        for c in "ZHHHWHHHEHHHEHHHWHHHWHHH":
            b.rotate(c)
            if self.isSameface(b):
                return True
        return False


def main():
    l = [int(x) for x in input().split()]
    k = [int(x) for x in input().split()]
    a = Dice(l)
    b = Dice(k)

    if a.isSame(b):
        print("Yes")
    else:
        print("No")


if __name__  == '__main__':
    main()



Measured memory_bytes: 5632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String str = input.readLine();
		
		int n1 = str.indexOf(" ");
		int n2 = str.indexOf(" " , n1 + 1);
		int n3 = str.indexOf(" ", n2 + 1);
		
		double x1 = Double.parseDouble(str.substring(0 , n1));
		double y1 = Double.parseDouble(str.substring(n1 + 1 , n2));
		double x2 = Double.parseDouble(str.substring(n2 + 1 , n3));
		double y2 = Double.parseDouble(str.substring(n3 + 1));
		
		double det = Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
		
		System.out.println(det);
		
	}

}

Measured memory_bytes: 16920
import sys
import copy
from collections import deque
import collections
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, d = na()

cnt = 0
for _ in range(n):
    x,y = na()
    if (x*x + y*y) <= d*d:
        cnt += 1

print(cnt)



Measured memory_bytes: 69504
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    string T = "keyence";
    int N = S.length();

    auto solve = [&]() {
        if (S == T) return true;
        REP(i, N) {
            FOR(j, i + 1, N) {
                string U = string(S.begin(), S.begin() + i)
                    + string(S.begin() + j, S.end());
                if (U == T) { return true; }
            }
        }
        return false;
    };

    YESNO(solve(), "YES", "NO");
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
     
     
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
     
    typedef int64_t ll;
     #define trace(x) cerr << #x << ": " << x << " " << endl;

    #define endl '\n'
    #define int ll
    ll mod=1e18;
    ll mod1=1e9+5;
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }

    
    int32_t main()
    {
        IOS
     

       int n;
       cin>>n;
       int a[n];
       for(int i=0;i<n;++i)
        cin>>a[i];
        
        int fin[n+1];
        memset(fin,0,sizeof(fin));
        for(int i=n;i>=1;--i)
        {
            int cnt=0;
            for(int j=i;j<=n;j+=i)
            {
                cnt+=fin[j];
            }
            if(cnt%2==a[i-1])
            {
                continue;
            }
            else
            {
                fin[i]++;
            }
        }
        for(int i=1;i<=n;++i)
        {
            int cnt=0;
            for(int j=i;j<=n;j+=i)
            {
                cnt+=fin[j];
            }
            if(cnt%2!=a[i-1])
            {
                cout<<-1;
                return 0;
            }
            
        }
        int cnt=0;
        for(int i=1;i<=n;++i)
        {
            if(fin[i])
                cnt++;
        }
        cout<<cnt<<endl;
        for(int i=1;i<=n;++i)
            if(fin[i])
                cout<<i<<" ";


    }

Measured memory_bytes: 3968
def tashi(n):
  c=str(n)
  return "0"*(6-len(c))+c
R=list()
N,M=map(int,input().split())
for i in range(M):
  P,Y=map(int,input().split())
  R.append([P,Y,i])
R=sorted(R)
f=1
k=0
for i in range(M):
  c=R[i]
  if c[0]==f:
    k+=1
    c.append(k)
  else:
    k=1
    c.append(k)
  f=c[0]
K=[0]*M
for i in range(M):
  c=R[i]
  K[c[2]]=tashi(c[0])+tashi(c[3])
for i in range(M):
  print(K[i])

Measured memory_bytes: 42268
d[99],f,l,i,T;main(t,w){for(;i=~scanf("%as",&w)?:!printf("%s %s\n",d[f],d[l]);t>T?T=t,l=i:0){for(;d[i+=2]&&strcmp(d[i],w););t=strlen(d[i]=w);++d[i+1]>d[f+1]?f=i:0;}}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n, k;
int a[100005];
int dp[100005];

int frog2(int index)
{
	if (index == n - 1)
		return 0;

	if (dp[index] != -1)
		return dp[index];

	int ans = INT_MAX;

	for (int i = index + 1; i <= min(n, index + k); ++i)
	{
		int x = abs(a[index] - a[i]) + frog2(i);

		ans = min(ans, x);
	}

	return dp[index] = ans;
}

int32_t main()
{
	FIO();

	cin >> n >> k;

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

	memset(dp, -1, sizeof(dp));

	cout << frog2(0) << '\n';
	return 0;
}

Measured memory_bytes: 9860
def ck(i,j):
  flag = True
  for a, b in zip(A[i:i+M], B):
    for aa, bb in zip(a[j:j+M], b):
      if aa != bb:
        flag = False
  return flag

f = False

N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

for i in range(N-M+1):
  for j in range(N-M+1):
    if A[i][j] == B[0][0]:
      if (ck(i,j)):
        f = True
        
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 41328
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int top,bot,sum,n,side[4],tmp;
	string s;

	while(1){
		cin>>n; if(n==0) return 0;
		top=1; bot=6; sum=1;
		side[0]=2;side[1]=3;side[2]=5;side[3]=4;
		for(int i=0;i<n;i++){
			cin>>s;
			if(s=="North"){
				top=side[0];side[0]=bot;side[2]=7-bot;
				bot=7-top;
			}else if(s=="East"){
				top=side[3];side[3]=bot;side[1]=7-bot;
				bot=7-top;
			}else if(s=="West"){
				top=side[1];side[1]=bot;side[3]=7-bot;
				bot=7-top;
			}else if(s=="South"){
				top=side[2];side[2]=bot;side[0]=7-bot;
				bot=7-top;
			}else if(s=="Right"){
				tmp=side[0];side[0]=side[1];side[1]=side[2];
				side[2]=side[3];side[3]=tmp;
			}else{
				tmp=side[0];side[0]=side[3];side[3]=side[2];
				side[2]=side[1];side[1]=tmp;
			}
			sum+=top;
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

/// template end ///



void solve()
{
	vector<int> r;
	REP(i, 1000)
		r.push_back(i + 1);

	while (true)
	{
		READ(int, n);
		if (!n) { break; }
		int ret = 0;
		
		REP(i, n) REP(j, n - i)
		{
			int x = accumulate(RANGEOF(r, i, j), 0);
			if (x == n) { ret++; }
			if (x >= n) { break; }
		}
		write(ret);
	}
}

Measured memory_bytes: 1224
import Control.Monad
main=do
 n<-readLn
 t<-replicateM n (map read.words<$>getLine)
 putStrLn(f n ([0,0,0]:t))
  where f 0 _ = "Yes"
        f n t = if(g (t!!0) (t!!1))then(f(n-1)(tail t))else"No"
        g x y = h ((y!!0)-(x!!0)) ((abs((y!!1)-(x!!1)))+(abs((y!!2)-(x!!2))))
        h t d = if t<d||(mod(t-d)2)==1 then False else True

Measured memory_bytes: 82300
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int N,k[111],p[111],ans[111],a[111];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> k[i] >> p[i];
    a[i]=k[i]/p[i];
    if(k[i]%p[i]==0){
      ans[i]=p[i];
    }else{
      ans[i]=k[i]-a[i]*p[i];
    }
  }
  for(int i=0;i<N;i++){
    cout << ans[i] << endl;
  }
  return(0);
}



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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    ll x, y;
    cin >> x >> y;

    vector<ll> ans(4, LONG_MAX);
    if (x <= y) ans[0] = y - x;
    if ((-1 * x) <= y) ans[1] = y - (-1 * x) + 1;
    if (x <= (-1 * y)) ans[2] = (-1 * y) - x + 1;
    if ((-1 * x) <= (-1 * y)) ans[3] = (-1 * y) - (-1 * x) + 2;

    ans[0] = min(ans[0], ans[1]);
    ans[0] = min(ans[0], ans[2]);
    ans[0] = min(ans[0], ans[3]);

    cout << ans[0] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main() {

	int a, b;
	bool f = 1;
	string s;
	cin >>a>>b>> s;

	for (int i = 0; i < s.size(); i++) {
		if (i != a && s[i] == '-')f = 0;
		if (s[a] != '-')f = 0;
	}

	if (f == 1)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 200010
#define int long long
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#pragma GCC optimize ("Ofast")

// debug_statment ...............................................................................
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug1(int a[], int l, int r) {
	vector<int> temp(a + l, a + r + 1);
	debug(temp);

}


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
// end_debug_statment .......................................................................

signed main(){
    IO;
    // freopen("input.txt", "r", stdin);
    int K;
    cin>>K;
    int output =0 ;
    for(int i = 1 ; i <= K ; i ++)
    	for(int j = 1 ; j <= K ; j ++)
    		for(int k = 1;k <= K ; k ++)
    			output += __gcd(i,__gcd(j,k));
   cout<<output;

    cout << setprecision(10) << fixed;
    return 0;
}




Measured memory_bytes: 3648
n, m = gets.strip.split.map(&:to_i)
data = m.times.map { gets.strip.split.map(&:to_i) }

n.times do |i|
  c = 0
  data.each do |d|
    c  += d.index(i+1).nil? ? 0 : 1
  end
  puts c
end

Measured memory_bytes: 14380
#include<stdio.h>

#define MAX 200000

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

Measured memory_bytes: 1376