akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;ll
#define Nmax 400005
#define OFF 100001
#define MOD 1000000007
using namespace std;

ll n, A[Nmax], B[Nmax];

ll solve(ll a, ll b){
    if (!(a%b)) return 0;
    return (a / b + 1) * b - a;
}

int main()
{
    cin >> n;
    for (int i=1;i<=n;i++) cin >> A[i] >> B[i];

    ll ans = 0;
    for (int i=n;i>=1;i--){
        ans += solve(A[i] + ans, B[i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a+b;
    int right = c+d;
    if(left>right) {
        cout << "Left" << endl;
    } else if(left==right) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;

int main()
{
	int ans = 0;
	string s, t;
	cin >> s >> t;
	for (unsigned int i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i])
			ans++;
	}
	cout << ans;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll res = 0;
    FOR(i, 1, n + 1)
    {
        ll sum_keta = 0;
        ll num = i;
        while (num > 0)
        {
            sum_keta += (num % 10);
            num /= 10;
        }
        if (sum_keta >= a && sum_keta <= b)
            res += i;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/*input
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/
 
// author - Madhav Thakker
 
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace std;
 
#define ll long long
#define ld long double
#define int ll
#define endl '\n'

typedef pair<int, int> pii; 
typedef pair<ld, ld> pdd;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 
 
// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
const int MOD = 1e9+7;
 
 
int fast_pow(int a, int b){
	int res = a, ret = 1;
	while(b>0){
		if(b%2)
			ret = (ret*res)%MOD;
		res = (res*res)%MOD;b/=2;
	}
	return ret;
}
 
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';
// str = to_string(n)
// stoi , stoll, stol
// sort(arr, arr+n, greater<int>());
// fill(prefix.begin(), prefix.end(), 0);
// 
// 
 
 
 
////
const int maxN = 1e5+700;
int a[maxN], b[maxN], c[maxN];
int dp[maxN][3];
////


signed main(){
 
	fastio;
	time_t time_t1, time_t2;
	time_t1 = clock();
 
	////////////////////////////////

	int t = 1;
	// cin >> t ;

	while(t--){

		int n;
		cin >> n;
		for (int i = 0; i < n; ++i){
			cin >> a[i] >> b[i] >> c[i];
		}
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		
		for (int i = 1; i < n; ++i){
			dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
			dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
			dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i];
		}
		int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
		cout << ans << endl;
	}
 	
	///////////////////////////////
	// 
 
	time_t2 = clock();
	// cerr << "time taken :" << time_t2 - time_t1 << endl;
 
	return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
 
    int x = scanner.nextInt();
    int y = scanner.nextInt();
 
    System.out.println(x * y + " " + 2*(x + y));
    scanner.close();
  }
}


Measured memory_bytes: 26192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
inline ll read(){
	ll x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		ch=getchar();
		if (ch=='-') w=-1;	
	}
	while (ch<='9' && ch>='0'){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*w;
}
inline ll Pow(ll x,ll y){
	ll res=1;
	while (y){
		if (y&1) res=res*x;
		x=x*x;
		y>>=1;
	}
	return res;
}
ll n,p,ans;
int main(){
	n=read(),p=read(),ans=1;
	if (n==1){
		printf("%lld\n",p);
		return 0;
	}
	for (ll i=2;i*i<=p;++i){
		if (p==1) break;
		if (!(p%i)){
			ll cnt=0;
			while (!(p%i)) ++cnt,p/=i;
			for (int j=1;j<=cnt/n;++j)
				ans*=i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        for (int i = 1 ; i <= n ; i++) {
            String s = Integer.toString(i);
            if (s.length() % 2 == 1) {
                c++;
            }
        }
        System.out.println(c);

    }

}


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

signed main() {
    int N;
    cin >> N;

    FOR(h, 1, 3501) {
        FOR(n, 1, 3501) {
            if(4*h*n-N*n-N*h <= 0) continue;
            if((N*h*n)%(4*h*n-N*n-N*h)==0) {
                cout << h << " " << n << " " << (N*h*n)/(4*h*n-N*n-N*h) << endl;
                return 0;
            } 
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  for(int i = 0;i < t;i++)cin >> a[i];

  sort(a.begin(),a.end());
  int sum = 0;
  for(int i = 0;i < t-1;i++)sum += a[i];

  cout << max(a[t-1]-sum-1,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT long long int
#define MOD 1000000007
#define oo (INT)(6e18)
using namespace std;
INT n, a[3][110], dt[3][110];
INT dp(int x, int y)
{
    if( x >= 2 or y >= n ) return -oo;
    if( x == 1 and y == n-1 ) return a[x][n-1];
    if( dt[x][y] ) return dt[x][y];
    INT &ret = dt[x][y] = 0;
    return ret = max( dp(x+1, y), dp(x, y+1) ) + a[x][y];
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < 2 ; i++ ) for(int j = 0 ; j < n ; j++ )
        cin>>a[i][j];
    cout<<dp(0, 0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll t,n,m;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    cout<<ceil(1.0*n/1000)*1000-n<<endl;
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>

int main() {
    using namespace std;

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int min = std::max(A, C);
    int max = std::min(B, D);

    if (max <= min) {
        cout << 0 << endl;
    } else {
        cout << max - min << endl;
    }
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		int[] arr1 = new int[n];
		for(int i=0;i<2*n;i++) {
			if(i%2==0) {
				arr[i/2]=sc.next();
			}
			else {
				arr1[i/2]=sc.nextInt();
			}
		}
		String x = sc.next();
		int sum=0;
		int d =0;
		for(int i=0;i<n;i++) {
			if(x.equals(arr[i])) {
				d=i;
				break;
			}
		}
		for( int y=d+1;y<n;y++) {
			sum=sum+arr1[y];
		}
		System.out.println(sum);
	}
}


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

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int sum = 0;
  cin >> s;

  for (char d : s)
  {
    // cout << d - '0';
    sum += (d - '0');
  }

  if (stoi(s) % sum)
    cout << "No\n";
  else
    cout << "Yes\n";

  return 0;
}

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

int main(){
    int n, k; cin >> n >> k;
    int c[n] = {0};
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int l;
            cin >> l;
            c[l-1]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(c[i] == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a%b;
	f = 1.00000*a / b;
	printf("%d %d %f\n", d, r, f);
	return 0;

}


Measured memory_bytes: 2740
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut A = read![[i64]];
    A.sort();

    let mut x = A[0] as f64;
    for i in 1..N {
        x = (x + A[i] as f64) / 2.0;
    }

    println!("{}", x)
}


Measured memory_bytes: 4352
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q, W, H;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		cout << s << endl << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
        ll n,m,i,j;
        cin>>n;
        map<pair<char,char>,ll> mp;
        for(i=1;i<=n;i++)
        {
            string s=to_string(i);
            mp[{s[0],s.back()}]++;
        }

        ll ans=0;
        map<pair<char,char> ,ll>::iterator it;
        for(it=mp.begin();it!=mp.end();it++)
        {
            if(it->first.first==it->first.second)
                ans+=it->second*it->second;
            else
            ans+=it->second*(mp[{it->first.second,it->first.first}]);
        }
        cout<<ans;
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

  int N;
  std::string S;
  std::cin >> N >> S;
  int ans = 0;
  rep (i, N - 2) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      ++ans;
    }
  }
  std::cout << ans << '\n';
  return 0;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.regex.*;
class Main{
	public static void main(String[]args){
		try{
			Pattern pat=Pattern.compile("A.*?Z");
			Matcher mat=pat.matcher(new BufferedReader(new InputStreamReader(System.in)).readLine());
			boolean f=false;
			for(;mat.find();){
				f=true;
				System.out.print("AZ");
			}
			System.out.println(f?"":"-1");
		}catch(IOException e){}
	}
}

Measured memory_bytes: 17084
s=input()
s=':'+s+':'
t='keyence*'
fo,ba=0,0
while s[fo+1]==t[fo]:
    fo+=1
t='*keyence'
while s[ba-2]==t[ba-1]:
    ba-=1
if fo-ba>6:
    print('YES')
else:
    print('NO')

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

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var s = lines[0].split('');
 var t = lines[1].split('');
 var ans = 'Yes';
 
 for(i=0; i<s.length; i++){
   if(s[i] !== t[i]){
     ans = 'No';
   }
 }
    if(s.length + 1 !== t.length){
    ans='No';
  }


 console.log(ans);
});

Measured memory_bytes: 30076
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=3e2+10;
#define fi first
#define se second
#define pb push_back
LL dis[N][N];
int n,m,l,vis[N];
struct uzi{
    int a;
    LL b;
    LL c;
    bool operator <(const uzi & t)const{
        if(c==t.c)return b<t.b;
        return c>t.c;
    }
};
vector<pair<int,int> >v[N];

LL tmp[N][N];
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>m>>l;
    for(int i=1;i<=m;i++){
        int s,t,w;
        cin>>s>>t>>w;
        v[s].pb({t,w});
        v[t].pb({s,w});
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i!=j)dis[i][j]=LLONG_MAX,tmp[i][j]=0;
            else dis[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        priority_queue<uzi>q;
        memset(vis,0,sizeof vis);
        q.push({i,l,0});
        tmp[i][i]=l;
        while(!q.empty()){
            auto now=q.top();
            q.pop();
            vis[now.a]=0;
            for(auto k:v[now.a]){
                int cost=k.se;
                int tmpa=tmp[i][now.a];
                if(tmpa>=cost){
                    if(dis[i][k.fi]<dis[i][now.a])continue;
                    if(dis[i][k.fi]==dis[i][now.a]){
                        if(tmp[i][k.fi]>=tmpa-cost)continue;
                    }
                    dis[i][k.fi]=dis[i][now.a];
                    tmp[i][k.fi]=tmpa-cost;
                    if(!vis[k.fi])q.push({k.fi,tmpa-cost,dis[i][now.a]}),vis[k.fi]=1;
                }else if(l>=cost){
                    int need=1;
                    cost=need*l-cost;
                    if(dis[i][k.fi]<dis[i][now.a]+need)continue;
                    if(dis[i][k.fi]==dis[i][now.a]+need){
                        if(tmp[i][k.fi]>=cost)continue;
                    }
                    tmp[i][k.fi]=cost;
                    dis[i][k.fi]=dis[i][now.a]+need;
                    if(!vis[k.fi])q.push({k.fi,cost,need+dis[i][now.a] }),vis[k.fi]=1;
                }else {
                    continue;
                }
            }
        }
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int s,t;
        cin>>s>>t;
        if(dis[s][t]==LLONG_MAX)cout<<-1<<endl;
        else cout<<dis[s][t]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N, A;
    cin >> N >> A;
    puts((N%500 <= A) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = scanner.nextDouble();

        double circleArea = r * r * Math.PI;
        double lengthOfCircumference = r * 2 * Math.PI;

        System.out.printf("%f %f", circleArea, lengthOfCircumference);
    }

}

Measured memory_bytes: 28236
from sys import stdin
from random import randint
from time import time
input = lambda: stdin.readline().rstrip()
start = time()
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.reverse()
ok = 0
t = time() - start
while t < 1.8:
    cnt = 0
    for i in range(n):
        if a[i] == b[i]:
            rng = randint(0, n - 1)
            b[i], b[rng] = b[rng], b[i]
            cnt += 1
    if cnt == 0:
        ok = 1
        break
    t = time() - start
if ok == 1:
    print("Yes")
    print(*b)
else:
    print("No")


Measured memory_bytes: 42004
#include<stdio.h>
long long int dp[1001][1001];
int main(void)
{
	long long int N,i,j,k,x=0,JOI[1001];
	char a[1001];
	scanf("%lld",&N);
	for(i=1;i<=N;i++){
		scanf(" %c",&a[i]);
	}
	for(i=1;i<=N;i++){
		JOI[i]=0;
		if(a[i]=='J'){
			JOI[i]+=4;  //printf("4 %d\n",i);
		}
		else if(a[i]=='O'){
			JOI[i]+=2;  //printf("2 %d\n",i);
		}
		else if(a[i]=='I'){
			JOI[i]+=1;  //printf("1 %d\n",i);
		}
	}
	for(i=1;i<=N;i++){									
		for(j=1;j<=7;j++){
			dp[i][j]=0;
		}
	}
	for(i=1;i<=7;i++){
		if((JOI[1]&i)!=0&&(4&i)!=0){
			dp[1][i]=1;
		}
	}
	for(i=1;i<N;i++){
		for(j=1;j<=7;j++){
			if(dp[i][j]!=0){
				for(k=1;k<=7;k++){
					if((JOI[i+1]&k)!=0&&(j&k)!=0){
						dp[i+1][k]+=dp[i][j];
					}
					if(dp[i+1][k]>=10007){
						dp[i+1][k]%=10007;
					}
				}
			}
		}
	}
	for(i=1;i<=7;i++){
		x+=dp[N][i];
	}
	/*for(i=1;i<=N;i++){
		for(j=1;j<=7;j++){
			printf("%lld ",dp[i][j]);
		}
		printf("\n");
	}*/
	printf("%lld\n",x%10007);
	return 0;
}

Measured memory_bytes: 6728
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
int main()
{
	int num;
	ll gen;
	scanf("%d%lld", &num, &gen);
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		v.push_back(make_pair(zb, 1));
		v.push_back(make_pair(za, 0));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0;; i++)
	{
		if (v[i].second == 0)
		{
			printf("%lld\n", ans + (gen + v[i].first - 1) / v[i].first);
			break;
		}
		else
		{
			ans++;
			gen -= v[i].first;
			if (gen <= 0)
			{
				printf("%lld\n", ans);
				break;
			}
		}
	}
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


int main(){
    int N, K; cin >> N >> K;
    ll res;
    if(K%2 == 0){
        int k=K/2;
        res=(ll)pow(N/k/2, 3)+(ll)pow((N/k+1)/2, 3);
    }
    else{
        res=(ll)pow(N/K, 3);
    }
    cout << res << endl;
    return 0;
}

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

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;
    vl a(N);
    REP(i, N) cin >> a[i];
    sort(ALL(a));

    int Q;
    cin >> Q;
    vector<pii> bc(Q);
    REP(i, Q) {
        int b, c;
        cin >> b >> c;
        bc[i] = pii(b, c);
    }

    ll ans = accumulate(ALL(a), 0LL);
    map<int, int> cnt;
    REP(i, Q) {
        int dif = bc[i].second-bc[i].first;
        int num = distance(a.begin(), lower_bound(ALL(a), bc[i].first+1)) - distance(a.begin(), lower_bound(ALL(a), bc[i].first));
        num += cnt[bc[i].first];
        
        cnt[bc[i].second] += num;
        cnt[bc[i].first] -= num;
        
        ans += dif*num;
        cout << ans << endl;
        
    }

    return 0;
}


Measured memory_bytes: 8664
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF =  10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  int sum = 0;
  
  cin >> a >> b;
  
  for(int i = 1; i < b - a; i++)
  {
    sum += i;
  }
  
  cout << sum - a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int N[6]={1,5,2,3,0,4},S[6]={4,0,2,3,5,1};
int E[6]={3,1,0,5,4,2},W[6]={2,1,5,0,4,3},O[6]={0,1,2,3,4,5};
int PT[8]={3,1,2,4,3,1,2,4};
void cpy(int *a,int *b,char dir){
    int i,*d;
    if (dir=='N'){d=N;}
    else if (dir=='S'){d=S;}
    else if (dir=='E'){d=E;}
    else if (dir=='W'){d=W;}
    else {d=O;}
    for(i=0;i<6;i++){b[i]=a[d[i]];}
}
int chk(int *a,int *b){
    int i;
    for(i=0;i<6;i++){
        if (a[i]!=b[i]){break;}
    }
    return (i==6)? 1:0;
}
int main(void){
    int i,j,q,buf,d[6],c[6],e[6],ca[8],cb[4],fl=0;
    for(i=0;i<6;i++){scanf("%d",&e[i]);}
    for(i=0;i<6;i++){scanf("%d",&d[i]);}
    while(1){
        if(chk(d,e)) break;
        if (d[1]==e[0] || d[4]==e[0] || d[5]==e[0]){cpy(d,c,'O');cpy(c,d,'N');}
        else if (d[3]==e[0] || d[2]==e[0]){cpy(d,c,'O');cpy(c,d,'E');}
        else {break;}
    }
    for(i=0;i<8;i++){
        ca[i]=e[PT[i]];
        if(i<4){cb[i]=d[PT[i]];}
    }
    for(i=0;i<5;i++){
        if (ca[i]==cb[0] && ca[i+1]==cb[1] && ca[i+2]==cb[2] && ca[i+3]==cb[3]){fl=1;break;}
    }
    printf("%s\n",(fl)? "Yes":"No");
    return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>


int main(void){
 
int i,j,N,minj,v,a[10000]; 
int c =0;

    scanf("%d", &N);
     for ( i = 0; i < N; i++ ){ 
scanf("%d", &a[i]);
}
 
 
for(i=0;i<N;i++){
minj=i;
for(j=i;j<N;j++){

            if ( a[j] < a[minj] ) {
      minj=j;
}
}
if(i!=minj){
               v = a[i];
                a[i] = a[minj];
                a[minj] = v;
                
               
c++;
            }
        }
    
   
    for ( i = 0; i < N; i++ ) {
if(i>0){
printf(" ");
}

        printf("%d", a[i]);
}
printf("\n");
  
    

    printf("%d\n",c);

    return 0;
}

Measured memory_bytes: 1784
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    vector<pair<long, long> > a(n), b(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld %ld", &(a[i].first), &(a[i].second) );
    }
    sort(a.begin(), a.end());

    for(i=0; i<n; i++) {
        scanf("%ld %ld", &(b[i].first), &(b[i].second) );
    }
    sort(b.begin(), b.end());

    long count=0;
    vector<long> aflag(n,0);
    long j;
    for(i=0; i<n; i++) {
        long ymax=-10000;
        long jsave=-1;
        for(j=0; j<n; j++) {
            if(!aflag[j] && a[j].first<b[i].first && a[j].second<b[i].second) {
                if(a[j].second > ymax) {
                    ymax=a[j].second;
                    jsave=j;
                }
            }
        }
        if(jsave>=0) {
            aflag[jsave] = 1;
            count++;
        }
    }
    printf("%ld\n", count);
 
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int[] height = new int[n];
    int[] cost = new int[n];
    Arrays.fill(cost, Integer.MAX_VALUE);
    cost[0] = 0;
    for(int i = 0; i < n; i++) height[i] = Integer.parseInt(sc.next());
    for(int i = 0; i < n; i++) {
      for(int j = 1; j <= k && i + j < n; j++) {
        cost[i+j] = Math.min(cost[i+j], cost[i] + Math.abs(height[i+j] - height[i]));
      }
    }
    System.out.println(cost[n-1]);
  }
}


Measured memory_bytes: 47112
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

// #define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,l;
char d[250];
int p[250];
bool goal[250];

int main(){
	while(1){
		int n,l;
		int ll,rr;
		cin >> n >> l;
		if(n==0&&l==0) break;
		REP(i,n){
			cin >> d[i] >> p[i];
			goal[i] = false;
		}
		int rest = n;
		int goaltime = 0;
		while(rest!=0){
			goaltime++;
			vector<int> posd[500];
			REP(i,500) posd[i].clear();
			REP(i,n){
				//if(p[i]!=-1) cout << i << " " << d[i] << " " << p[i] << endl;
			}
			REP(i,n){
				if(goal[i]) continue;
				if(p[i]<=0||p[i]==l) continue;
				if(d[i]=='L') p[i]--;
				else p[i]++;
				if(p[i]>=0) posd[p[i]].pb(i);
			}
			FOR(i,1,l){
				if(posd[i].size()==2){
 					swap(d[posd[i][1]],d[posd[i][0]]);
				}
			}
			ll = -1; rr = -1;
			REP(i,n){
				if(p[i]==0){
					p[i]=-1;
					ll = i;
					rest--;
				}
				if(p[i]==l){
					p[i]=-1;
					rest--;
					rr = i;
				}
			}
		}
		int ans;
		if(ll==-1&&rr!=-1) ans = rr;
		else if(ll!=-1&&rr==-1) ans = ll;
		else ans = ll;
		cout << goaltime << " " << ans+1 << endl;

	}
}

Measured memory_bytes: 1228
use itertools::iproduct;
use proconio::input;
use std::collections::HashSet;

#[allow(unused_mut)]
fn main() {
    input! {
        n: usize
    };
    let mut pattern = HashSet::new();
    for (i, j) in iproduct!(1..10, 1..10) {
        pattern.insert(i * j);
    }
    if pattern.insert(n) {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 2116
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

long long int INF = 1000000000000000000LL; // 10^18
using namespace std;

typedef pair<int, int> P;

long long int A_[110000], B_[110000], C_[110000];
long long int A[110000], B[110000], C[110000];

long long int DP1[110000] = {};
long long int DP2[110000] = {};

int main(){
	
	long long int X, Y, Z, N;
	cin >> X >> Y >> Z;
	
	N = X + Y + Z;
	
	vector<P> v;
	for(int i = 0; i < N; i++){
		cin >> A_[i] >> B_[i] >> C_[i];
		P p;
		p.first = A_[i] - B_[i];
		p.second = i;
		v.push_back(p);
	}
	
	sort(v.begin(), v.end(), greater<P>());
	
	for(int i = 0; i < N; i++){
		int ind = v[i].second;
		A[i] = A_[ind];
		B[i] = B_[ind];
		C[i] = C_[ind];
		//cout << A[i] << " " << B[i] << " " << C[i] << endl;
	}
	
	priority_queue<long long int> que, que2;
	long long int S = 0;
	
	for(int i = 0; i < X; i++){
		S += A[i];
		que.push(C[i] - A[i]);
	}
	DP1[X] = S;
	
	for(int i = X; i < X + Z; i++){
		S += A[i];
		que.push(C[i] - A[i]);
		S += que.top();
		que.pop();
		DP1[i + 1] = S;
	}
	
	sort(v.begin(), v.end());
	
	for(int i = 0; i < N; i++){
		int ind = v[i].second;
		A[i] = A_[ind];
		B[i] = B_[ind];
		C[i] = C_[ind];
	}
	
	S = 0;
	
	for(int i = 0; i < Y; i++){
		S += B[i];
		que2.push(C[i] - B[i]);
	}
	DP2[Y] = S;
	
	for(int i = Y; i < Y + Z; i++){
		S += B[i];
		que2.push(C[i] - B[i]);
		S += que2.top();
		que2.pop();
		DP2[i + 1] = S;
	}
	
	long long int ans = 0;
	for(int i = 0; i <= N; i++){
		ans = max(ans, DP1[i] + DP2[N - i]);
		//cout << DP1[i] << " " << DP2[i] << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7924
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;

    cin >> n;
    for (int i = 0; i < n; i++) {
        string str;
        int num1, num2;

        cin >> str;

        sort(str.begin(), str.end());
        num1 = atoi(str.c_str());

        reverse(str.begin(), str.end());
        num2 = atoi(str.c_str());

        cout << num2 - num1 << endl;
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, K;
  cin >> N >> K;
  vi32 A(N);
  cin >> A;
  int sum = 0;
  rep(i, N) sum += A[i];
  vi32 divisors;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      divisors.emplace_back(i);
      if (i != sum / i) divisors.emplace_back(sum / i);
    }
  }
  int ans = 0;
  each(d, divisors) {
    pqasc<int> q;
    i64 su = 0;
    rep(i, N) {
      int a = (A[i] / d) * d;
      int c = A[i] - a;
      q.emplace(-c);
      su += -c;
    }
    while (su != 0) {
      int v = q.top(); q.pop();
      su += d;
    }
    int s = 0;
    while (q.size()) {
      s -= q.top(); q.pop();
    }
    if (s <= K) amax(ans, d);
  }
  cout << ans << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

bool possible(ll S, ll c, ll make) {
  if (S < make) {
    c -= (make - S) * 2;
  }
  return c / 2 >= make;
}

int main2() {
  ll S; cin >> S;
  ll c; cin >> c;
  ll hi = c + 1;
  ll lo = 0;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (possible(S, c, mid)) lo = mid; else hi = mid;
  }
  cout << lo << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int main(void){
	int ALL;
	int A, B, C, D;
	char sign_str[3];
	int i, j, k;

	scanf("%d", &ALL);

	A = ALL/1000;
	B = (ALL/100)%10;
	C = (ALL/10)%10;
	D = ALL%10;

	for(i=-1;i<2;i+=2)
	{
		for(j=-1;j<2;j+=2)
		{
			for(k=-1;k<2;k+=2)
			{
				if(A+B*i+C*j+D*k == 7)
				{
					sign_str[0] = i==1 ? '+':'-';
					sign_str[1] = j==1 ? '+':'-';
					sign_str[2] = k==1 ? '+':'-';
					printf("%d%c%d%c%d%c%d=7\n", A, sign_str[0], B, sign_str[1], C, sign_str[2], D);
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
typedef pair<string,pii>psi;
int n;
psi a[110];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].F>>a[i].S.F,a[i].S.F*=-1,a[i].S.S=i;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)cout<<a[i].S.S<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

signed main()
{
	int mp[3][3];
	REP(i, 3) {
		REP(j, 3)
			scnaf("%d", &mp[i][j]);
	}


	REP(i, 2) {
		int sa = mp[i + 1][0] - mp[i][0];
		REP(j, 3) {
			if (mp[i + 1][j] - mp[i][j] != sa) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	REP(i, 2) {
		int sa = mp[0][i + 1] - mp[0][i];
		REP(j, 3) {
			if (mp[j][i + 1] - mp[j][i] != sa) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    int a,b;
    cin >> a >> b;
    if(a%2==1&&b%2==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


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

int main(){
    vector<int> A(3);
    for(int i = 0; i < 3; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());

    cout << A.at(0) * A.at(1) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int N; cin >> N;
    vector<int> x(N), y(N), h(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> h[i];

    for (int posY = 0; posY <= 100; ++posY) {
        for (int posX = 0; posX <= 100; ++posX) {
            // needH: -1 working, -2 error, other numbers find
            int needH = -1;
            for (int i = 0; i < N; ++i) {
                if (h[i] > 0) {
                    int temp = h[i] + abs(posX - x[i]) + abs(posY - y[i]);
                    if (needH == -1) {
                        needH = temp;
                    } else if (needH != temp) {
                        needH = -2;
                        break;
                    }
                }
                if (needH == -2) continue;
            }
            for (int i = 0; i < N; ++i) {
                if (h[i] == 0) {
                    int dist = abs(posX - x[i]) + abs(posY - y[i]);
                    if (needH > dist) {
                        needH = -2;
                        break;
                    }
                }
            }
            if (needH == -2) continue;

            cout << posX << " " << posY << " " << needH << endl;
        }
    }
}

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

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int a = 0;
            for (int b = 0; b < s.Length-1; b++)
            {
                if (s[b] != s[b + 1])
                    a++;
            }
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 3032
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let kx: Vec<isize> = read_vec();
    let k = kx[0];
    let x = kx[1];

    let ans = if (500 * k) >= x {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2112
# coding: utf-8
# Your code here!

H, W = map(int, input().rstrip().split(' '))

field = []
for _ in range(H):
    temp_field = []
    for s in input():
        temp_field.append(0 if s == '.' else 1)
    field.append(temp_field)
    
dp = [[0] * (W + 1) for _ in range(H+1)]
dp[0][1] = 1

for h in range(1, H+1):
    for w in range(1, W+1):
        if field[h-1][w-1] == 0:
            dp[h][w] = dp[h-1][w] + dp[h][w-1]
            
print(dp[-1][-1] % (1000000007))


Measured memory_bytes: 165216
y = 0

datas = $stdin.read.split("\n")

while true
	if datas[0].to_i - datas[1].to_i - datas[2].to_i * y < 0
		y -= 1
		puts datas[0].to_i - datas[1].to_i - datas[2].to_i * y
		break
	end
	y += 1
end

Measured memory_bytes: 1788
#include <iostream>

using namespace std;
typedef long long ll;
ll a[200010],b[200010],sum1[200010],sum2[200010];
int main(){
    int i,n,m;
    ll k;
    cin >> n >> m >> k;
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<m;i++) cin >> b[i];
    for(i=1;i<=n;i++) sum1[i] = sum1[i - 1] + a[i - 1];
    for(i=1;i<=m;i++) sum2[i] = sum2[i - 1] + b[i - 1];
    int ans = 0;
    int r = m;
    for(i=0;i<=n;i++){
        ll x = sum1[i];
        if(x>k) break;
        while(sum2[r] + x>k){
            r--;
        }
        ans = max(ans,i + r);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9788
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  
  char ans = '#';
  for (char c = 'a'; c <= 'z'; c++) {
    bool flag = false;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == c) flag = true;
    }
    if (!flag && ans == '#') ans = c;
  }
  
  // 解答
  if (ans == '#') cout << "None" << endl;
  else cout << ans << endl;
  
  return 0;
}
  

Measured memory_bytes: 512
#include<iostream>
#include<cassert>
#include<algorithm>
using namespace std;


int MOD;



template<class T=long long>
class Matrix{
	int _row,_col;
	T* p;
public:
	Matrix():_row(0),_col(0),p(0){}
	Matrix(int row,int col):_row(row),_col(col){
		p=new T[_row*_col];
	}
	Matrix(const Matrix& a):_row(-1),p(0){
		copy(a);
	}
	~Matrix(){
		delete[] p;
	}
	int row()const{return _row;}
	int col()const{return _col;}
	void resize(int r,int c){
		if(_row*_col!=r*c){
			delete[] p;
			p=new T[r*c];		
		}
		_row=r;
		_col=c;
	}
	void swap(Matrix& a){
		std::swap(_row,a._row);
		std::swap(_col,a._col);
		std::swap(p,a.p);
	}
	void copy(const Matrix& a){
		resize(a._row,a._col);
		for(int i=0;i<row();i++)
			for(int j=0;j<col();j++)
				p[i*col()+j]=a[i][j];
	}
	T* operator[](int i)const{return p+(i*_col);}
	Matrix& operator =(const Matrix &a){
		copy(a);
		return *this;
	}
	Matrix& operator *=(const Matrix &a){
		(*this*a).swap(*this);
		return *this;
	}
	Matrix operator *(const Matrix &a)const{
		assert(col()==a.row());
		Matrix res(row(),a.col());
		for(int i=0;i<row();i++){
			for(int j=0;j<a.col();j++)res[i][j]=0;
			for(int k=0;k<col();k++){
				T da=p[i*col()+k];
				const T * const __restrict pb=a[k];
				T * const __restrict pc=res[i];
				for(int j=0;j<a.col();j++){
					pc[j] = (pc[j]+da*pb[j])%MOD;
				}
			}
		}
		return res;
	}
	Matrix pow(int n)const{
		assert(row()==col());
		int size=row();
		Matrix res(size,size),x(*this);
		for(int i=0;i<size;i++){
			for(int j=0;j<size;j++)res[i][j]=i==j;
		}
		while(n){
			if(n&1){
				(res*x).swap(res);
			}
			(x*x).swap(x);
			n>>=1;
		}
		return res;
	}
};



int main(){
	int n,a,b,c,t;
	while(cin>>n>>MOD>>a>>b>>c>>t,n|MOD|a|b|c|t){
		Matrix<> p(n,n),s(n,1);
		for(int i=0;i<n;i++)cin>>s[i][0];

		for(int i=0;i<n;i++)for(int j=0;j<n;j++)p[i][j]=0;
		for(int i=0;i<n;i++){
			if(i!=0)p[i][i-1]=a;
			p[i][i]=b;
			if(i+1<n)p[i][i+1]=c;
		}
		s=p.pow(t)*s;
		cout<<s[0][0];
		for(int i=1;i<n;i++){
			cout<<' '<<s[i][0];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280