akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 3000000000000000000;

int main() {
    int N;
    cin >> N;
    
    vector<ll> cnt(N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j <= N; j += i) ++cnt[j];
    }
    
    ll ans = 0;
    rep(i, N + 1) ans += cnt[i] * i;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 81392
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
const int MAXN = 1e6 + 50;
int A[MAXN];

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C; cin >> A >> B >> C;
    cout << min(C, B/A);

}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int n;
char str[100001];
char ans2[100001];
int check(char* ans,char last,int flag)
{
	if(flag==1)
		return 1;
	for(int i=1;i<=n-2;i++)
	{
		if(ans[i]=='S')
		{
			if(str[i]=='o')
			{
				ans[i+1]=ans[i-1];
			}
			if(str[i]=='x')
			{
				if(ans[i-1]=='S')
					ans[i+1]='W';
				if(ans[i-1]=='W')
					ans[i+1]='S';
			}
		}
		else if(ans[i]=='W')
		{
			if(str[i]=='x')
			{
				ans[i+1]=ans[i-1];
			}
			if(str[i]=='o')
			{
				if(ans[i-1]=='S')
					ans[i+1]='W';
				if(ans[i-1]=='W')
					ans[i+1]='S';
			}
		}
	}
	char temp;
	if(ans[n-1]=='S')
		{
			if(str[n-1]=='o')
			{
				temp=ans[n-2];
			}
			if(str[n-1]=='x')
			{
				if(ans[n-2]=='S')
					temp='W';
				if(ans[n-2]=='W')
					temp='S';
			}
		}
		else if(ans[n-1]=='W')
		{
			if(str[n-1]=='x')
			{
				temp=ans[n-2];
			}
			if(str[n-1]=='o')
			{
				if(ans[n-2]=='S')
					temp='W';
				if(ans[n-2]=='W')
					temp='S';
			}
		}
		
	if(ans[n-1]==last&&temp==ans[0])
	{

		for(int i=0;i<n;i++)
			ans2[i]=ans[i];
		return 1;
	}
	else
		return 0;
}
int main(void)
{
	scanf("%d",&n);
	scanf(" %s ",str);
	char ans[n];
	int flag=0;
	if(str[0]=='o')
	{
		ans[0]='S';
		ans[n-1]='S';
		ans[1]='S';
		flag=flag|check(ans,ans[n-1],flag);
		ans[n-1]='W';
		ans[1]='W';
		flag=flag|check(ans,ans[n-1],flag);
		ans[0]='W';
		ans[1]='S';
		ans[n-1]='W';
		flag=flag|check(ans,ans[n-1],flag);
		ans[1]='W';
		ans[n-1]='S';
		flag=flag|check(ans,ans[n-1],flag);
	}
	else if(str[0]=='x')
	{
		ans[0]='S';
		ans[n-1]='W';
		ans[1]='S';
		flag=flag|check(ans,ans[n-1],flag);
		ans[n-1]='S';
		ans[1]='W';
		flag=flag|check(ans,ans[n-1],flag);
		ans[0]='W';
		ans[1]='S';
		ans[n-1]='S';
		flag=flag|check(ans,ans[n-1],flag);
		ans[1]='W';
		ans[n-1]='W';
		flag=flag|check(ans,ans[n-1],flag);
	}
	if(flag==0)
		printf("-1\n");
	else
	{
		for(int i=0;i<n;i++)
			printf("%c",ans2[i]);
	}
}

Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input);
});

function Main(input) {
    input = input.split(/\r?\n/);
    var n = input[0];
    if (n[0] == n[2]) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }
}



Measured memory_bytes: 20812
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int q(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void) {
  int n,cnt=0;
  scanf("%d",&n);
  int a[n][3];
  FOR(n){
    FORJ(3)scanf("%d",&a[i][j]);
    qsort(a[i],3,sizeof(int),q);
    FORJ(i){
      if(a[i][0]==a[j][0]&&a[i][1]==a[j][1]&&a[i][2]==a[j][2]){
        cnt++;
        break;
      }
    }
  }
  PRN(cnt);
  return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll fun(vector<ll> &v,ll n,ll k)
{
  if( k >= n)
    return 0;
  sort(v.begin(),v.end(),greater<int>());
  for(ll i=0;i<k; i++)
     v[i]=0;
  ll sum=0;
  for(ll i=0;i<v.size();i++)
     sum+=v[i];
 return sum;
  
}
int main()
{
// h;cin>>h;
ll n;cin>>n;
ll k;cin>>k;
  vector<ll> v(n);
  for(ll i=0;i<n;i++)
     cin>>v[i];
 cout<<fun(v,n,k);
  return 0;
}

Measured memory_bytes: 1792
package main

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

var as []int

func solve() {
	n := getInt()
	as = getIntSlice(n)

	ans1 := calc(1)
	ans2 := calc(-1)

	ans := min(ans1, ans2)
	fmt.Fprintln(wr, ans)
}

func calc(x int) int {
	ret := 0
	now := 0
	for _, a := range as {
		now += a
		if now == 0 {
			now += x
			ret++
		} else {
			if (now > 0) != (x > 0) {
				ret += abs(now) + abs(x)
				now = x
			}
		}
		x *= -1
	}

	return ret
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

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

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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


Measured memory_bytes: 3072
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int A, B, K;
    cin >> A >> B >> K;

    int X = A < B ? A : B;

    vector<int> div = {};
    for (int i = 1; i * i <= X; i++)
    {
        if (A % i == 0 && B % i == 0)
            div.PB(i);

        if (i != X / i && A % (X / i) == 0 && B % (X / i) == 0)
            div.PB(X / i);
    }

    sort(ALL(div), greater<int>());
    cout << div[K - 1] << endl;

    return 0;
}


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


int main() {
  int h,n; cin >> h >> n;
  vector<int> battle(n);
  int sum=0;
  
  for(int i=0; i < n; i++){
    int x; cin >> x;
    sum += x;
  }
  
  if(h - sum <= 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n;
  int loop,path,tmp;
  long long int k;
  int a[200001]={0};
  int town[200001]={0,1};
  int i;

  scanf("%d %lld",&n,&k);
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i+1]);
  }

  i=1;
  tmp=1;
  while(1)
  {
    if(i==k)
    {
      printf("%d\n",a[tmp]);
      return 0;
    }
    if(town[a[tmp]]>0)
    {
      loop=i+1-town[a[tmp]];
      path=town[a[tmp]];
      break;
    }
    else town[a[tmp]]=i+1;
    i++;
    tmp=a[tmp];
  }

  k=(k-path+1)%loop+path;

  for(i=1;i<=200000;i++)
  {
    if(town[i]==k)
    {
      printf("%d\n",i);
      break;
    }
  }

  return 0;
}

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

int main()
{
    int N,X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i = 0;i < N;i++){
        cin >> L[i];
    }
    int ad = 0;
    int ans = 1;
    for (int i = 0;i < N;i++) {
        ad+=L[i];
        if(X >= ad){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

const int MXN=100005;
int par[MXN];
int rnk[MXN];
//union_find(親par,深さrnk)

void union_init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        rnk[i]=0;
    }
}

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

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        return;
    }
    if(rnk[x]<rnk[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(rnk[x]==rnk[y]){
            rnk[x]++;
        }
    }
}
//集合が同じか
bool same(int x,int y){
    return find(x)==find(y);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    union_init(N);
    vl p(N),q(N);
    rep(i,N){
        cin >> p[i];
        p[i]--;
        q[p[i]]=i;
    }
    rep(i,M){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        unite(x,y);
    }
    /*rep(i,N){
        cout << par[i] << endl;
    }*/
    int ans=0;
    rep(i,N){
        if(same(i,q[i])){
            ans++;
        }
    }
    cout << ans << endl;
}


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

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    data.assign(n, -1);
  }
  int root(int k) {
    if (data[k] < 0) return k;
    return data[k] = root(data[k]);
  }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int size(int k) {
    return -data[root(k)];
  }
};

vector<int> z_algorithm(string &s) {
  int n = s.size();
  vector<int> a(n);
  a[0] = s.size();
  int i = 1, j = 0;
  while (i < s.size()) {
    while (i + j < s.size() && s[j] == s[i + j]) j++;
    a[i] = j;
    if (j == 0) { i++; continue; }
    int k = 1;
    while (i + k < s.size() && k + a[k] < j) a[i + k] = a[k], k++;
    i += k, j -= k;
  }
  return a;
}

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
 
  string ss = s;
  while (ss.size() < t.size()) ss += s;
  ss += ss;
  int sn = ss.size();
  ss = t + ss;

  auto za = z_algorithm(ss);
  
  auto uf = UnionFind(n);
  for (int i = t.size(); i < t.size() + n; i++) {
    if (za[i] < t.size()) continue;
    int x = i - t.size();
    int y = (x + t.size()) % n;
    if (!uf.unite(x, y)) {
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15376
#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;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
// #define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;

#define pi 3.1415926535897932

void solve()
{
	int s,n;
	cin >> s >> n;

	int ans = 0;
	loop(i,0,n)
	{
		cin >> A[i];
		ans += A[i];
	}

	if(s-ans < 0)cout << -1;
	else cout << s-ans;

}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

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

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(
    s: usize,
    w: usize,
    );
    let ans = if w >= s {"unsafe"} else {"safe"};
    println!("{}", ans);
}


Measured memory_bytes: 2108
#include <stdio.h>

int main(void){
	int h,w,i;

	while(1){
		scanf("%d %d",&h,&w);

		if(h==0 && w == 0){
			return 0;
		}

		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n");
		h--;

		while(h>1){
			i=w;
			while(i>0){

				if(i==w || i==1){
					printf("#");
				}
				else{
					printf(".");
				}
				i--;
			}
			printf("\n");
			h--;
		}

		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
}


Measured memory_bytes: 1984
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    }
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int sg[110000],x,y,n;
vector<int> ve[110000]; 
void dfs(int x, int f) {
	sg[x] = 0;
	for (int i = 0; i < ve[x].size(); i++) {
		if (ve[x][i] == f) continue;
		dfs(ve[x][i], x);
		sg[x] = sg[x] ^ (sg[ve[x][i]] + 1);
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d %d", &x, &y);
		ve[x].push_back(y);
		ve[y].push_back(x); 
	}
	dfs(1,0);
	if (sg[1] == 0) cout<<"Bob"<<endl; else cout<<"Alice"<<endl;
}

Measured memory_bytes: 12544
from collections import defaultdict
N, M = list(map(int, input().split()))
YP = []
for _ in range(M):
    p, y = list(map(int, input().split()))
    YP.append([y, p])

sortedYP = sorted(YP)

Pcount = defaultdict(int)
ansYear = {}

for m in range(M):
    y, p = sortedYP[m]
    Pcount[p] += 1
    ansYear[y] = Pcount[p]

for m in range(M):
    y, p = YP[m]
    print(str(p).zfill(6) + str(ansYear[y]).zfill(6))


Measured memory_bytes: 36616
#include <iostream>
using namespace std;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
int a[maxn],b[3];
int main ()
{
    int n;
    cin >> n;
    for (int i = 0; i < n ;i ++) cin >> a[i];
    long long int sum = 1, k,num;
    for (int i = 0; i < n ;i ++)
    {
        k = 0;
        for (int j = 0; j < 3; j ++)
        {
            if(a[i] == b[j])
                k ++, num = j;
        }
        sum =(sum * k) % mod;
        b[num] ++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
using mint = modint998244353;

mint ones[200005];

struct S {
  mint a;
  int size;
};
struct F {
  int a, i;
};

S op(S l, S r){
  mint x = mint(10).pow(r.size);
  return S{l.a*x+r.a, l.size+r.size};
}
S e(){
  return S{0,0};
}
S mapping(F l, S r){
  if(l.i == -1) return r;
  return S{ones[r.size] * l.a, r.size};
}
F composition(F l, F r){
  if(l.i < r.i) return r;
  return l;
}
F id(){
  return F{1, -1};
}

int main(){
  {
    mint p(1);
    REP(i,1,200005){
      ones[i] = p;
      p = p*10+1;
    }
  }
  int N, Q;
  cin >> N >> Q;

  vector<S> v;
  rep(i,N){
    v.push_back(S{1,1});
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

  rep(q,Q){
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    seg.apply(l, r+1, F{d,q});
    cout << seg.all_prod().a.val() << endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 11976
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ENDL '\n'
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR_EACH(i, v) for (auto&& i : v)

long long* memo;

long long calc(string s)
{
	int len = s.length();

	if (memo[len - 1]) {
		return memo[len - 1];
	}

	long long sum = stoll(s);
	for (int i = 1; i < len; i++) {
		sum += stoll(s.substr(0, i)) * (long long)pow(2, len - i - 1) + calc(s.substr(i));
	}
	memo[len - 1] = sum;
	return sum;
}

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

	string S;
	cin >> S;
	int len = S.length();
	memo = new long long[len];
	FOR(i, len) {
		memo[i] = 0LL;
	}

	cout << calc(S) << ENDL;

	delete memo;
	return 0;
}

Measured memory_bytes: 3952
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    bool f=0;
    if( a == b && a != c)f=1;
    if( a == c && a != b)f=1;
    if( c == b && a != c)f=1;
    if(f){
        cout << "Yes" << endl;
        return 0;
    }
    cout <<"No"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}

const int Max=1e7+9;
const int OO=-1e6;
int st[4]= {1,0,0,-1};
int nt[4]= {0,1,-1,0};
int n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
ll mem[100009][109];
void init()
{
    memset(mem,-1,sizeof mem);
}
//////////////////////////////////////////////////////////

ll a[106];
ll v[106];

ll solve (int i=0,int weight=0 )
{
    if(i==n)return 0;
    ll &ret=mem[weight][i];
    if(~ret)return ret;
   ll leave=solve(i+1,weight);
   ll take=0;
   if(weight+a[i]<=m)
    take=solve(i+1,weight+a[i])+v[i];
   return mem[weight][i]=max(leave,take);
}

void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
   init();
   n =D();
    m =D();
   for(int i=0; i<n;i++)
   {
       a[i]=D();
       v[i]=D();
   }
   printf("%lld",solve());

}


Measured memory_bytes: 88936
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(L[K-1])

Measured memory_bytes: 3060
import collections
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
s_set=collections.Counter(s)
t_set=collections.Counter(t)
score=[]
for w in s_set:
    score+=[s_set[w]-t_set[w]]
print(max(score) if max(score)>0 else 0)
    

Measured memory_bytes: 3316
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;


public class Main {
	public static class FastReader {
			BufferedReader br;
			StringTokenizer root;
			
	 
			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	 
			String next() {
				while (root == null || !root.hasMoreTokens()) {
					try {
						root = new StringTokenizer(br.readLine());
					} catch (Exception addd) {
						addd.printStackTrace();
					}
				}
				return root.nextToken();
			}
	 
			int nextInt() {
				return Integer.parseInt(next());
			}
	 
			double nextDouble() {
				return Double.parseDouble(next());
			}
	 
			long nextLong() {
				return Long.parseLong(next());
			}
	 
			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception addd) {
					addd.printStackTrace();
				}
				return str;
			}
		}
	 
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static FastReader sc = new FastReader();
 
	static long mod = (int) (1000000000),MAX=(int)(1e5+10);
	
	public static void main(String[] args) throws IOException{
		
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i=0;i<n;++i) a[i] = sc.nextLong();
		sort(a);
		long ans = a[0];
		int k = n-2;
		for(int i=1;i<n && k > 0;++i) {
			ans+=a[i]; --k;
			if(k > 0) {
				ans+=a[i];
				--k;
			}
			
		}
		out.print(ans);
	out.close();
	}
	
	static void sort(long[] A) {
        PriorityQueue<Long> pq = new PriorityQueue<>();
        int i = 0;
        for (i = 0; i < A.length; i++)
            pq.add(-1*A[i]);
        for (i = 0; i < A.length; i++)
            A[i] = -1*pq.poll();
    }
	
}





Measured memory_bytes: 57404
string = input()

loop = int(input())

data = []

for i in string:
	data.append(i)

for i in range(loop):
	operate = input().split()

	if operate[0] == "replace":
		a = int(operate[1])
		b = int(operate[2])
		trans = []
		for i in operate[3]:
			trans.append(i)
		ope = 0
		for i in range(a, b+1):
			data[i] = trans[ope]
			ope += 1
	elif operate[0] == "reverse":
		a = int(operate[1])
		b = int(operate[2])
		trans = []
		for i in range(a,b+1):
			trans.append(data[b-i+a])

		ope = 0

		for i in range(a, b+1):
			data[i] = trans[ope]
			ope += 1

	else:	
		a = int(operate[1])
		b = int(operate[2])
		for i in range(a, b+1):
			print(data[i], end = "")
		print()


Measured memory_bytes: 5744
#include <stdio.h>

int main() {
	int N, X;
	scanf("%d %d", &N, &X);
	int L[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	int tmp = 0, point = -1;
	for (int i = 0; i < N; i++) {
		tmp += L[i];
		if (tmp > X) {
			point = i + 1;
			break;
		}
	}
	if (point == -1) printf("%d\n", N + 1);
	else printf("%d\n", point);
	return 0;
}

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

#define ll long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++);
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}
map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	long long h, w;
	cin >> h >> w;
	long long ans = 0;
	if (w != 1 && h != 1) { 
		ans += (w / 2 + w % 2) * (h / 2 + h % 2) + (w / 2) * (h / 2);
	}

	else {
		ans += 1;
	}
	
	cout << ans;
	return 0;
}









Measured memory_bytes: 256
import math
import itertools


# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


x = int(input())
if x == 0:
    print(1)
else:
    print(0)

Measured memory_bytes: 62224
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

ll fact(int x){
    if(x == 1) return 1;
    else return x*fact(x-1);
}

int a[1010];


int main(){

    int n;
    cin >> n;
    ll mod = 1e9 + 7;

    int root = int(sqrt(n)) + 5;

    for(int j=2; j<=n; j++){
        int tmp = j;
        for(int i=2; i<root; i++){
            int cnt = 0;
            while(tmp % i == 0){
                tmp /= i;
                cnt++;
            }
            a[i] += cnt;
        }
        if(tmp != 1) a[tmp] += 1;
    }

    ll sum = 1;
    for(int k=0; k<1010; k++){
        sum *= (a[k]+1);
        sum = sum % MOD;
    }

    cout << sum << endl;



    /**
    ll fact_n = fact(n);


    if(n != 1){
        //素朴に解いてみる
        for(int i=1; i<=fact_n; i++){
            if( fact_n%i == 0) cnt++;
        }
    }

    ll ans = cnt % mod;
     **/


}

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

int main() {

  int H,W;
  cin >> H >> W;

  vector<vector<int>> c(10,vector<int>(10)),A(H+1,vector<int>(W+1));

  for(int i = 0;i < 10;i++) {
    for(int j = 0;j < 10;j++) {
      cin >> c.at(i).at(j);
    }
  }

  
  for(int i = 1;i <= H;i++) {
    for(int j = 1;j <= W;j++) {
      cin >> A.at(i).at(j);
    }
  }

  int d[10],seen[10],D[10];

  D[1] = 0;

  for(int k = 0;k < 10;k++) {

    for(int i = 0;i < 10;i++) {
      d[i] = 100000000;
      seen[i] = 0;
    }

    d[k] = 0;

    while(true) {

      int mini = 100000000,u = 0;
      for(int i = 0;i < 10;i++) {
        if(!seen[i] && mini > d[i]) {
          mini = d[i];
          u = i;
        }
      }

      seen[u] = 1;

      if(seen[1]) {
        D[k] = d[1];
        break;
      }
      
      for(int i = 0;i < 10;i++) {
        if(!seen[i] && d[i] > d[u] + c.at(u).at(i)) {
          d[i] = d[u] + c.at(u).at(i);
        }
      }
    }
  }

  int ans = 0;
  for(int i = 1;i <= H;i++) {
    for(int j = 1;j <= W;j++) {
      if(A.at(i).at(j) != -1) ans += D[A.at(i).at(j)];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static final String LEFT = "LEFT";
    public static final String RIGHT = "RIGHT";
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int w = Integer.parseInt(strArr[0]);
            int a = Integer.parseInt(strArr[1]);
            int b = Integer.parseInt(strArr[2]);
            int ans = 0;
            if (a < b) {
                if (a + w >= b) {
                    ans = 0;
                } else {
                    ans = b - (a + w);
                }
            } else {
                if (b + w >= a) {
                    ans = 0;
                } else {
                    ans = a - (b + w);
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const long long mod = 1e9 + 7;
const int N = 2e5 + 10;
int n, k;
long long f[N], res;

void init() {
	k = min(k, n - 1);
	f[0] = 1;
	for (long long i = 1; i <= 2e5; i++)
		f[i] = f[i - 1] * i % mod;
}

long long power(long long x, int y) {
	long long res = 1;
	while (y) {
		if (y & 1) res = res * x % mod;
		x = x * x % mod;
		y /= 2;
	}

	return res;
}

long long modinv(long long x) {
	return power(x, mod - 2);
}

long long comb(int n, int r) {
	return f[n] * modinv(f[n - r] * f[r] % mod) % mod;
}

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

	init();

	for (int i = 0; i <= k; i++)
		res = (res + comb(n, i) * comb(n - 1, i)) % mod;

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
// AtCode_Beginner_160.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	C();
}

void A() {
	string s;
	cin >> s;
	


	cout << ((s[2] == s[3]) && (s[4] == s[5]) ? "Yes" : "No") << endl;

}

void B() {
	int n;
	cin >> n;

	int sum = n - n % 500;
	sum *= 2;
	sum += (n % 500) - (n % 5);

	cout << sum << endl;

}

void C() {

	int K, N;
	cin >> K >> N;

	vector<int> points(N);

	for (int& num : points) cin >> num;

	sort(points.begin(), points.end());

	int maxDistance = 0;

	for (int i = 0; i < N; i++) {

		int dif = points[(i + 1) % N] - points[i];
		if (i == N-1) dif = K + dif;
		if (dif > maxDistance) maxDistance = dif;

	}

	cout << K - maxDistance;

}

void D() {
	/*int N, X, Y;
	cin >> N >> X >> Y;

	vector<int> pair{ X, Y };

	vector<int> results(N);

	int distance = Y - X;


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

		int def = N - i;
		if (i == ) results[i] = def;
		if (i == distance) results[i] = def + 1;
		if (i > distance) results[i] = def - 1;

		cout << results[i] << endl;

	}*/

	




}


void E() {

	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<int> R(A);
	vector<int> G(B);
	vector<int> W(C);
	 
	for (int& r : R) cin >> r;
	for (int& g : G) cin >> g;
	for (int& w : W) cin >> w;


	sort(R.begin(), R.end());
	sort(G.begin(), G.end());
	sort(W.begin(), W.end());

	reverse(R.begin(), R.end());
	reverse(G.begin(), G.end());
	reverse(W.begin(), W.end());

	long long total = 0;

	int a = 0, b = 0, c = 0;

	while (a + b < X + Y) {

		long long mRed = a != A ? R[a] : -1;
		long long mGreen = b != B ? G[b] : -1;
		long long mWhite = c != C ? W[c] : -1;

		//need more reds or greens
		if (X-a > 0 && Y-b > 0) {
			if (mRed > mGreen) {
				if (mRed > mWhite) {
					total += mRed;
					a++;
				}
				else {
					total += mWhite;
					c++;
					Y--;
				}
			}
			else {
				if (mGreen > mWhite) {
					total += mGreen;
					b++;
				}
				else {
					total += mWhite;
					c++;
					X--;
				}
			}
			

		}
		else if (X-a > 0) {
			if (mRed > mWhite) {
				total += mRed;
				a++;
			}
			else {
				total += mWhite;
				c++;
				X--;
			}
		}
		else {
			if (mGreen > mWhite) {
				total += mGreen;
				b++;
			}
			else {
				total += mWhite;
				c++;
				Y--;
			}


		}
		

	}
	

	cout << total;

}

int helper(int N, int K) {

	while (N >= K) {
		if (N % K == 0) N /= K;
		else N %= K;
	}

	return N == 1;

}

void F() {

	int N;
	cin >> N;

	vector<bool> factor(N, false);

	int count = 2;

	for (int n = 2; n * n < N; n++) {

		int divisible = false;
		if (N % n == 1) count++;
		else if (N % n == 0) if (helper(N, n)) count++;
		/*
		//hasnt been done before
		if (!factor[n]) {

			divisible = (N % n == 0);

			for (int i = n; i < N; i+=n) {
				factor[i] = true;

				if (divisible) {
					if(helper(N, i)) count++;
				}

			}

		}*/

	}

	cout << count;

}

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

int main() {
  int x, ans = 0;
  cin >> x;
  ans += x / 500 * 1000;
  ans += (x % 500) / 5 * 5;
  cout << ans;
}

Measured memory_bytes: 3596
using System;

class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split();

            int N = int.Parse(line[0]);
            int A = int.Parse(line[1]);
            int B = int.Parse(line[2]);


            int trainFee = N * A;
            int taxiFee = B;

            if (trainFee >= taxiFee)
            {
                Console.WriteLine(taxiFee);
            }
            else
            {
                Console.WriteLine(trainFee);
            }
        }
    }

Measured memory_bytes: 13140
//
//AtCoder Beginner Contest 174
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    int ans = 0;
    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        if (sqrt(x*x + y*y) <= d) ans ++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e5 + 10;
pair<ll, ll> x[N];
const ll good_value = 0, inf = 1e18; // 0 for sum, -inf for max, and inf for min
int n;
ll d, a;
ll t[4 * N], ch[4 * N];

ll merge(ll p, ll q) {
	return p + q;
}

void build(int v = 1, int tl = 1, int tr = n) {
    if (tl == tr) {
        t[v] = x[tl].S;
        return;
    }
    int tm = (tl + tr)/2;
    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);
    t[v] = merge(t[v + v], t[v + v + 1]);
}

void push(int v, int tl, int tr) {
    if (!ch[v]) return;
    t[v] += ch[v] * 1ll * (tr - tl + 1); // r - l + 1 for sum and 1 for min/max
    if (tl < tr) {
        ch[v + v] += ch[v];
        ch[v + v + 1] += ch[v];
    }
    ch[v] = 0;
}

void update(int l, int r, ll x, int v = 1, int tl = 1, int tr = n) {
    push(v, tl, tr);
    if (r < tl || tr < l) return;
    if (l <= tl && tr <= r) {
        ch[v] += x;
        push(v, tl, tr);
        return;
    }
    int tm = (tl + tr)/2;
    update(l, r, x, v + v, tl, tm);
    update(l, r, x, v + v + 1, tm + 1, tr);
    t[v] = merge(t[v + v], t[v + v + 1]);
}

ll get(int l, int r, int v = 1, int tl = 1, int tr = n) {
    push(v, tl, tr);
    if (r < tl || tr < l) return good_value;
    if (l <= tl && tr <= r) return t[v];
    int tm = (tl + tr)/2;
    ll res = merge(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
    t[v] = merge(t[v + v], t[v + v + 1]);
    return res;
}

ll get(int pos) {
    return get(pos, pos);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> d >> a;
    for (int i=1; i<=n; i++) {
        cin >> x[i].F >> x[i].S;
    }
    sort(x + 1, x + n + 1);
    build();
    ll ans = 0, l = 1, r = 1;
    while (l <= n) {
        ll cur = get(l);
        if (cur <= 0ll) {
            l++;
            continue;
        }
        while (x[r+1].F - x[l].F <= d + d && r + 1 <= n) {
            r++;
        }
        ans += (cur + a - 1) / a;
        update(l, r, (cur + a - 1) / a * (-a));
        l++;
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 15872
package main

import (
   "fmt"
)

func solution(c [3][3]int) string {
   var a, b [3]int
   a[0] = 0
   for i := 0; i < 3; i++ {
        b[i] = c[0][i]
   }
   for i := 1; i < 3; i++ {
        a[i] = c[i][0] - b[0]
   }

   for i := range c {
        for j := range c[i] {
                if c[i][j] != a[i]+b[j] {
                        return "No"
                }
        }
   }
   return "Yes"
}

func main() {
   var c [3][3]int
   for i := 0; i < 3; i++ {
        for j := 0; j < 3; j++ {
                fmt.Scan(&c[i][j])
        }
   }
   fmt.Println(solution(c))
}

Measured memory_bytes: 1836
import collections
N = int(input())
S = []

res = []
for i in range(N):
    S.append(input())

SS = collections.Counter(S)
m = max(SS.values())
for i in SS.keys():
    if(SS[i]== m):
        res.append(i)
res.sort()
for i in range(len(res)):
    print(res[i])

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

int main(){
    string s;
    cin>>s;
    vector<int>a,b;
    for(int i=0;i<s.size()-2;i++){
        a.push_back(abs(stoi(s.substr(i,3))-753));
    }
    cout<<*min_element(a.begin(),a.end());
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

int dx[] = {1,-1, 0, 0};
int dy[] = {0, 0,-1, 1};
int h,w;
char s[30][30];
int dist[30][30];

int bfs(int i, int j){
      int res = 0;
      if(s[i][j] == '#') return -1;
      memset(dist,-1,sizeof(dist));
      dist[i][j] = 0;
      queue<pair<int,int>> q;
      q.push(make_pair(i,j));
      while(!q.empty()){
            auto p = q.front(); q.pop();
            int x = p.first, y = p.second;
            chmax(res,dist[x][y]);
            rep(i,4){
                  int nx = x + dx[i], ny = y + dy[i];
                  if(nx >= 0 && ny >= 0 && nx <= h-1 && ny <= w-1){
                        if(dist[nx][ny] != -1 || s[nx][ny] == '#') continue;
                        dist[nx][ny] = dist[x][y] + 1;
                        q.push(make_pair(nx,ny));
                  }
            }
      }
      return res;
}

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      cin >> h >> w;
      rep(i,h)rep(j,w) cin >> s[i][j];

      int ans = 0;

      rep(i,h)rep(j,w) chmax(ans,bfs(i,j));
      
      cout << ans << endl;
      
      return 0;
}

Measured memory_bytes: 256
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c; cin>>a>>b>>c;
	if(a==c) cout<<b;
	else if(a==b) cout<<c;
	else cout<<a;
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include<cstdio>

int S[1000000],T[500000];

int binarySearch(int x,int n){
  int key = T[x];
  int left = 0;
  int right = n;
  int mid;
  
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key){
      return mid;
    }else if(key < S[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }

  return -1;
}

int main(){
  int n,q,cnt = 0;
  int ans;
  std::scanf("%d",&n);

  for(int i = 0;i < n;i++){
    std::scanf("%d",&S[i]);
  }

  std::scanf("%d",&q);

  for(int i = 0;i < q;i++){
    std::scanf("%d",&T[i]);
  }

  for(int i = 0;i < q;i++){
    ans  = binarySearch(i,n);
    if(ans != -1){
      cnt++;
    }
  }
  
  std::printf("%d\n",cnt);

  return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
int main(void){
    ll D;
    cin >> D;
    
    if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
    else if (D == 23) cout << "Christmas Eve Eve" << endl;
    else if (D == 24) cout << "Christmas Eve" << endl;
    else if (D == 25) cout << "Christmas" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#ifndef _MSC_VER
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
#endif

using namespace std;

#define LOCAL 0
#define ll long long

int main()
{
#if LOCAL == 1
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    
    ll a, b, c;
    cin >> a >> b >> c;
    
    ll s1 = a * b;
    ll s2 = b * c;
    ll s3 = a * c;
    
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        cout << 0;
    else 
        cout << min({ s1, s2, s3 });
    
    return 0;
}


Measured memory_bytes: 256
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;


template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

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

map<ll,ll> s1;
map<ll,ll> s2;



int main(){
	ll n,q;
	cin >> n >> q;
	ll ans = (n-2)*(n-2);
	s1.insert(mp(0,n-2));
	s2.insert(mp(0,n-2));
	rep(_,q){
		ll a,b;
		cin >> a >> b;
		if(a == 1){
			decltype(s1)::iterator it = s1.lower_bound(b);
			--it;
//			prints(it->first);

			ans-=it->second;
			s1.insert(mp(b,it->second));
			if(it->first == 0)s2[0]=b-2;
		}
		else{
			decltype(s2)::iterator it = s2.lower_bound(b);
			--it;
//			prints(it->first);
			ans-=it->second;
			s2.insert(mp(b,it->second));
			if(it->first == 0)s1[0]=b-2;
		}
//		prints(ans);
	}
	prints(ans);


	return 0;
}




Measured memory_bytes: 16124