akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

int main(){
    cin>>N;
    rep(i,N) {
        cin>>A;
        if(i == 0) {
            B = A;
            continue;
        }
        B = extgcd(max(A,B), min(A,B),H,W);
    }
    cout<<B<<endl;
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 15
#define mp make_pair
#define pb push_back
#define ll long long
#define uint unsigned int
#define pii pair<int, int>
#define ull unsigned long long
#define sz(v) ((int)(v).size())
#define gc() fgetc(stdin)
template<typename T> void read(T &a) {
	register int b = 1, c; a = 0;
	for (c=gc(); c > 57 || c < 48; c=gc()) if (c == 45) b = -1;
	for (; c >= 48 && c <= 57; c=gc()) a = a * 10 + c - 48;
	a *= b;
}

bool matched[N];
string s[N], ss[N];
int n, m, match[N], match1[N];

void solve_col(int i, bool flag) {
	if (i == m) {
		puts("YES\n");
		exit(0);
	}
	if (~match1[i]) {
		solve_col(i + 1, flag);
		return;
	}
	for (int j = 0; j < m; j++) {
		if (j == i) continue;
		if (~match1[j]) continue;
		bool same = 1;
		for (int k = 0; k < n; k++) {
			if (s[k][i] != s[match[k]][j]) {
				same = 0;
				break;
			}
		}
		if (!same) continue;
		match1[i] = j;
		match1[j] = i;
		solve_col(i + 1, flag);
		match1[j] = -1;
	}
	if (flag) {
		bool same = 1;
		for (int j = 0; j < n; j++) {
			if (s[j][i] != s[match[j]][i]) {
				same = 0;
				break;
			}
		}
		if (same) {
			match1[i] = i;
			solve_col(i + 1, 0);
		}
	}
	match1[i] = -1;
}

void solve_row(int i, bool flag) {
	if (i == n) {
		memset(match1, -1, sizeof match1);
		solve_col(0, m & 1);
		return;
	}
	if (~match[i]) {
		solve_row(i + 1, flag);
		return;
	}
	for (int j = 0; j < n; j++) {
		if (j == i) continue;
		if (ss[j] != ss[i]) continue;
		if (~match[j]) continue;
		match[i] = j;
		match[j] = i;
		solve_row(i + 1, flag);
		match[j] = -1;
	}
	if (flag) {
		match[i] = i;
		solve_row(i + 1, 0);
	}
	match[i] = -1;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		ss[i] = s[i];
		sort(ss[i].begin(), ss[i].end());
	}
	memset(match, -1, sizeof match);
	solve_row(0, n & 1);
	puts("NO\n");
	return 0;
}

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

using namespace std;
int main(void){
    string S,rS;

    cin >> S;

    if(S.size() == 2){
        cout << S << endl;
        exit(0);
    }
    else{
        reverse(S.begin(), S.end());
        cout << S << endl;
        exit(0);
    }

    return 0;

}

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

int main(){
	int a[3][3];
	int n;
	int b[10];
	int i=0;
	int j=0;
	int k=0;
	int l=0;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>b[i];
	}
	for(k=0;k<n;k++){
		for(i=0;i<3;i++){
			for(j=0;j<3;j++){
				if(b[k]==a[i][j])a[i][j]=0;
			}
		}
	}
	for(i=0;i<3;i++){
		if(a[i][0]==a[i][1] && a[i][1]==a[i][2])l=l+1;
	}
	for(i=0;i<3;i++){
		if(a[0][i]==a[1][i] && a[1][i]==a[2][i]) l=l+1;
	}
	if(a[0][0]==a[1][1] && a[1][1]==a[2][2]) l=l+1;
	if(a[0][2]==a[1][1] && a[1][1]==a[2][0]) l=l+1;
	if(l==0) cout<<"No";
	if(l>0) cout<<"Yes";
}

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

int N;

int main()
{
    cin>>N;
    vector<int> v(N);
    for (int i=0; i<N; i++) cin>>v.at(i);
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    int a=0,b=0;
    for (int i=0; i<N; i++) {
        if (i%2==0) a+=v.at(i);
        else b+=v.at(i);
    }
    cout<<a-b<<endl;
    return 0;
}


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

char str[109][20];

int same(int x)
{
	int i;
	for (i = 0; i < x; ++i)
		if (strcmp(str[i], str[x]) == 0)
			return 1;
	return 0;
}

int main(void)
{
	int n, i;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s", str[i]);
		if (same(i)) {
			puts("No");
			return 0;
		}
		if (i && str[i - 1][strlen(str[i - 1]) - 1] != str[i][0]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] == cnt + 1) cnt++;
    }
    if (!cnt) cout << -1 << endl;
    else cout << n - cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll conbination(ll index)
{
    ll ans;
    ans = index * (index - 1) / 2;
    return ans;
}

int main()
{
    long long N;
    cin >> N;
    vector<long long> a(N);
    vector<long long> b(N, 0);
    int count = 0;
    while (count < N)
    {
        long long input;
        cin >> input;
        a.at(count) = input;
        b.at(input - 1)++;
        count++;
    }

    vector<long long> ans(N);
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += conbination(b.at(i));
    }
    for (int i = 0; i < N; i++)
    {
        long long k = sum;
        k -= b.at(a.at(i) - 1) - 1;
        ans.at(i) = k;
    }

    for (int i = 0; i < N; i++)
    {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 7296
#include <stdio.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int res = 0;
  int n;
  int i;

  scanf ( "%d", &n );
  while ( n-- )
  {
    int d;

    scanf ( "%d", &d );
    for ( i = 2; i * i <= d; ++i )
    {
      if ( d % i == 0 ) break ;
    }
    res += !!( i * i > d );
  }
  printf ( "%d\n", res );

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

int main() {
	int N;
	cin >> N;
	int temp = N;

	int sum = 0;
	while (N) {
		sum += N % 10;
		N /= 10;
	}

	if (temp%sum == 0) cout << "Yes\n";
	else cout << "No\n";
	
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 1e9 + 7;
const int N = 2e5 + 10, M = 1e2 + 30;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi aaos(-1)
#define mk make_pair

int a[N];
int cnt[N];
int vis[N];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (!vis[a[i]])
        {
            vis[a[i]] = 1;
            ll num = cnt[a[i]];
            ans += num * (num - 1) / 2;
        }
    }
    for (int i = 0; i < n; i++)
    {
        ll res = ans;
        ll num = cnt[a[i]];
        res -= num * (num - 1) / 2;
        num--;
        res += num * (num - 1) / 2;
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
int main()
{
	int n,a,b;
	scanf("%d",&n);
	if(n==1)
	{
		printf("Hello World");
	}
	
	else
	{
		scanf("%d%d",&a,&b);
		printf("%d",a+b);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, int>> p(n);
  rep(i, n) {
    int a, b, c;
    cin >> a >> b >> c;
    p[i] = make_tuple(a, b, c);
  }
  int dp[3][n];
  rep(i, 3) rep(j, n) dp[i][j] = 0;
  dp[0][0] = get<0>(p[0]);
  dp[1][0] = get<1>(p[0]);
  dp[2][0] = get<2>(p[0]);
  repi(i, 1, n) {
    rep(j, 3) {
      if (j == 0) {
        dp[j][i] = max(dp[j][i], get<0>(p[i]) + dp[1][i - 1]);
        dp[j][i] = max(dp[j][i], get<0>(p[i]) + dp[2][i - 1]);
      }
      if (j == 1) {
        dp[j][i] = max(dp[j][i], get<1>(p[i]) + dp[0][i - 1]);
        dp[j][i] = max(dp[j][i], get<1>(p[i]) + dp[2][i - 1]);
      }
      if (j == 2) {
        dp[j][i] = max(dp[j][i], get<2>(p[i]) + dp[0][i - 1]);
        dp[j][i] = max(dp[j][i], get<2>(p[i]) + dp[1][i - 1]);
      }
      /* rep(k, 3) {
        if (j == k) continue;
        dp[j][i] = max(dp[j][i], get<k>(p[i]) + dp[j][i - 1]);
      } */
    }
  }
  /* rep(i, n) {
    rep(j, 3) cout << dp[j][i] << " ";
    cout << endl;
  } */
  cout << max({dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]}) << endl;
  return 0;
}


Measured memory_bytes: 2560
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
	static long gcd(long a,long b)
	{
		if(b==0)
		{
			return a;
		}
		
		else
		{
			return gcd(b,a%b);
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();long[] arr=new long[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextLong();
		}
		
		long curr=arr[0];
		
		for(int i=1;i<n;i++)
		{
			
		//	out.println(curr);
			
			long gcd=gcd(arr[i],curr);
			
			long p1=curr/gcd,p2=arr[i];
			
			curr=(p1*p2);
		}
		
		out.println(curr);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
  string s;cin>>s;
  int a=10*(s[0]-'0')+s[1]-'0';
  int b=10*(s[2]-'0')+s[3]-'0';
  bool c=false,d=false;
  if(a>0&&a<13)c=true;
  if(b>0&&b<13)d=true;
  string k;
  if(c){
    if(d)k="AMBIGUOUS";
    else k="MMYY";
  }
  else{
    if(d)k="YYMM";
    else k="NA";
  }
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define modulo 1000000007
#define pb emplace_back

void solve(){
int n=0,q=0,x=0,y=0,k=0,m=0;
string s;
 cin>>n>>q;
cout<<n*q<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
    int t=1;
	//cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
} 

Measured memory_bytes: 3640
from collections import Counter

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

dp = [Counter()]
# [何個使ったか][sum]
dp[0][0] = 1
for i,j in enumerate(x):
	dp.append(Counter())
	for k in reversed(range(i+1)):
		for m,n in dp[k].items():
			dp[k+1][m+j] += n

res = 0
for l in dp:
	res += l[0]
print(res-1)

Measured memory_bytes: 5620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int sum = 0;
        int min = Integer.MAX_VALUE;
        int eat = 0;
        
        for (int i = 1; i <= n; i++) {
            eat = l + i - 1;
            //System.out.println(min);
            if (Math.abs(eat) < Math.abs(min)) {
                min = eat;
            }
        }
        
        //System.out.println(min);

        for (int i = 1; i <= n; i++) {
            sum += l + i - 1;
        }

        System.out.println(sum - min);

        sc.close();
    }
}

Measured memory_bytes: 21716
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main()
{_
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << setprecision(9) << fixed << ((1ll*w*h)/2.0) << ' ' << (1.0*x == w/2.0 and 1.0*y == h/2.0);
  return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(i32);
    println!("ABC{}", n);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;

int main(){
    int n;
    cin >> n;
    vector<int> b(n),a(0);
    rep(i,n) cin >> b.at(i);
    list<int> c;
    reverse(b.begin(),b.end());
    rep(i,n) c.push_back(b.at(i));
    rep(i,n){
        auto it=c.begin();
        rep(j,n-i){
            if (*it==n-i-j){
                //cout << *it << endl;
                c.erase(it);
                a.push_back(*it);
                break;
            }
            it++;
            if (j==n-i-1) {cout << -1 << endl;return 0;}
        }
    }
    rep(i,n) cout << a.at(n-i-1) << endl;
}


Measured memory_bytes: 256
# 全体のマスを開始位置でスライス、料金所だけ抽出し、要素の個数で条件分岐
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

square = list(range(0, N + 1))

a = square[:X + 1]
b = square[X:]

a_costs = []
b_costs = []

for i in a:
    if i in A:
        a_costs.append(i)
for i in b:
    if i in A:
        b_costs.append(i)

a_cost = len(a_costs)
b_cost = len(b_costs)

if a_cost > b_cost:
    print(b_cost)
else:
    print(a_cost)


Measured memory_bytes: 9148
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int N;
vector<int> a;
int dp[3010][3010][2];

int rec(int l, int r, int turn) {
  if (l > r) return 0;
  if (dp[l][r][turn]) return dp[l][r][turn];

  int res, next = (turn + 1) % 2;
  if (turn % 2 == 0) {
    res = max(rec(l + 1, r, next) + a[l], rec(l, r - 1, next) + a[r]);
  } else {
    res = min(rec(l + 1, r, next) - a[l], rec(l, r - 1, next) - a[r]);
  }

  return dp[l][r][turn] = res;
}

signed main() {
  int N;
  cin >> N;
  a.resize(N, 0);
  for (int i = 0; i < N; i++) cin >> a[i];
  cout << rec(0, N - 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 141696
#include <stdio.h>

int N, M;
char A[2048][2048];
char B[2048][2048];

int main(void) {
	int i, j;
	int count = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%2047s", A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if (scanf("%2047s", B[i]) != 1) return 1;
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			if (A[i][j] != B[i][j]) count++;
		}
	}
	printf("%d\n", count);
	return 0;
}



Measured memory_bytes: 9752
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 7;

int deg[5];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    for (int i = 0; i < 3; i++) {
        int u, v;
        cin >> u >> v;
        deg[u]++;
        deg[v]++;
    }

    map<int, int> cnt;
    for (int i = 1; i <= 4; i++) {
        cnt[deg[i]]++;
    }

    if (cnt[1] == 2 && cnt[2] == 2) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}



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

int main() {
	int s; cin >> s;
  	switch(s % 10) {
      case 0: case 1: case 6: case 8: cout << "pon"; break;
      case 2: case 4: case 5: case 7: case 9: cout << "hon"; break;
      case 3: cout << "bon"; break;
      default: return 0;
    }
  	return 0;
}


Measured memory_bytes: 3648
h,w,n = map(int,input().split())
d = {}
for i in range(n):
    a,b = map(int,input().split())
    a,b = a-1,b-1

    am1_f = a-1 > 0
    ap1_f = a+1 < h-1
    bm1_f = b-1 > 0
    bp1_f = b+1 < w-1
    a_f = a > 0 and a < h-1
    b_f = b > 0 and b < w-1

    am1 = a-1
    ap1 = a+1
    bm1 = b-1
    bp1 = b+1

    if am1_f:
        baseid = am1 * w
        if b_f:
            pid = baseid + b

            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bm1_f:
            pid = baseid + bm1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bp1_f:
            pid = baseid + bp1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

    if ap1_f:
        baseid = ap1*w
        if b_f:
            pid = baseid + b

            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bm1_f:
            pid = baseid + bm1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bp1_f:
            pid = baseid + bp1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1
    if a_f:

        baseid = a * w
        if b_f:
            pid = baseid + b
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bm1_f:
            pid = baseid + bm1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bp1_f:
            pid = baseid + bp1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1
    # print(d)

ans = [0 for i in range(10)]

for val in d.values():
    ans[val] += 1

ans[0] = (h-2)*(w-2)-sum(ans)

for a in ans:
    print(a)

Measured memory_bytes: 190520
// -*- coding:utf-8-unix -*-

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        s: String
    }
    println!("{}", if s == "ABC".to_string() { "ARC" } else { "ABC" });
}


Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct UnionFind
{
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;

  UnionFind(int N)
  {
    r = vector<int>(N, -1);
  }

  int root(int x)
  {
    if (r[x] < 0)
      return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (r[x] > r[y])
      swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x)
  {
    return -r[root(x)];
  }
};

int main()
{
  int N, M;

  cin >> N >> M;
  UnionFind tree(N);

  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    tree.unite(a, b);
  }

  //最大の友達集合を求める
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans = max(ans, tree.size(i));
  }

  cout << ans << endl;
}

Measured memory_bytes: 4028
a = '#.'*151
while True:
    x = 0
    (h,w) = map(int, raw_input().split())
    if h==w==0: break
    while x < h :
        if x%2==0:
            print a[0:w]
            x+=1
        else:
            print a[1:w+1]
            x+=1
    print ''

Measured memory_bytes: 4208
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=5e4+10;
const int M=N*10*10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t;
char a[maxn];
int main()
{
    int i,j;
    scanf("%s",a);
    for(i=0;a[i];i++)putchar(a[i]!=','?a[i]:' ');
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(h, w, n);
    cout << ceil(1.0*n/max(h, w)) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 764
#include<cstdio>

int n,a[51],sum,i;

int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]!=i+1)sum++;
	}
	if(sum<3)printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long lint;

int main(){
    lint n,x;
    cin>>n>>x;
    lint L[n];
    for(lint i=0;i<n;i++)
        cin>>L[i];
        lint i=0;
        lint d=0;
    while(d<=x){
        d+=L[i];
		i++;
    }
    cout<<i;

    return 0 ;
}

Measured memory_bytes: 256
N = int(input())
words = list(input())

for i in range(len(words)):
    check_word  = ord(words[i]) + N 
    if(check_word > ord('Z')):
        print(chr(ord('A') + (check_word - ord('Z'))-1),end="")
    else:
        print(chr(check_word),end="")
print()


Measured memory_bytes: 4596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MOD = 998244353;

void add(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}

void sub(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}

int mul(int a, int b) {
  return (int) ((a * 1LL * b) % MOD);
}

int mpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int minv(int x) {
  return mpow(x, MOD - 2);
}

int dp[310][310][310];

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  string s; int k;
  while (cin >> s >> k) {
    s += '0';
    vector<int> cnts;
    {
      int cnt = 0;
      for (char c : s) {
        if (c == '1') {
          cnt++;
        } else {
          cnts.push_back(cnt);
          cnt = 0;
        }
      }
    }
    int total = accumulate(cnts.begin(), cnts.end(), 0);
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    int prefix_tot = 0;
    for (int pos = 0; pos < (int)cnts.size(); pos++) {
      prefix_tot += cnts[pos];
      for (int cnt = 0; cnt <= total; cnt++) {
        for (int cost = 0; cost <= cnt; cost++) {
          for (int next = max(0, prefix_tot - cnt); cnt + next <= total; next++) {
            int add_cost = max(0, next - cnts[pos]);
            add(dp[pos + 1][cnt + next][cost + add_cost], dp[pos][cnt][cost]);
          }
        }
      }
    }
    int ans = 0;
    for (int cost = 0; cost <= total && cost <= k; cost++) {
      add(ans, dp[cnts.size()][total][cost]);
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 120096
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    double c=(a+b)/2.0;
    int d=(a+b)/2;
    if(d*1.0+0.000001>c) printf("%d",d);
    else
    printf("%d",d+1);
    return 0;
}

Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s, string t) {
    int n = cast(int) s.length;

    if (s == t) return n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i + j == n) {
                return n + i;
            }

            if (s[i + j] != t[j]) break;
        }
    }

    return n * 2;
}

void main() {
    readint;
    string s = read!string;
    string t = read!string;
    writeln(calc(s, t));
}


Measured memory_bytes: 256
#include <stdio.h>

int sumofintegers(int n,int s,int t,int u,int v){
  int a=0,b,c,d,i,j,k;
  b=t+1;
  for(i=v;i<10;i++){
    if((c=u+i)>s) break;
    if(n==b && s==c){
      a=1;
      break;
    } else {
      if((d=i+1)>9) break;
      a+=sumofintegers(n,s,b,c,d);
    }
  }
  return a;
}

int main(){
  int n,s;
  int a[10],i,j,k;
  while(scanf("%d %d",&n,&s)){
    if(n==0 && s==0) break;
    printf("%d\n",sumofintegers(n,s,0,0,0));
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int64 mod = 1000000007;

int64 powmod(int64 a, int64 n) {
    if (n == 0) return 1;
	if (n % 2 == 1) return a * powmod(a, n - 1) % mod;
	int64 x = powmod(a, n / 2);
	return x * x % mod;
}

int64 inv(int64 a) {
    return powmod(a, mod - 2);
}

int64 fact(int64 n) {
    int64 ans = 1;
	for (int64 i = 1; i <= n; ++i) {
		ans *= i;
		ans %= mod;
    }
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
	    cout << "0" << endl;
		return 0;
	}
	int n = (x + y) / 3;
	if (x < n) {
	    cout << "0" << endl;
		return 0;
	}
    if (y < n) {
	    cout << "0" << endl;
		return 0;
	}
	x -= n;
	y -= n;
	int64 ans = fact(x + y);
	ans *= inv(fact(x));
	ans %= mod;
	ans *= inv(fact(y));
	ans %= mod;
	
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF  = 0x3f3f3f3f3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = 200005;

int64 n,k;
int64 arr[MAXN], tree[4*MAXN], lazy[4*MAXN];

void push_up(int rt) {
    tree[rt] = min(tree[rt << 1],tree[rt << 1 | 1]);
}

void push_down(int rt, int len) {
    tree[rt << 1] += lazy[rt];
    lazy[rt << 1] += lazy[rt];
    tree[rt << 1 | 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
}
#define lchild rt << 1, l, m
#define rchild rt << 1 | 1, m + 1, r
void build(int rt = 1, int l = 1, int r = n) {
    if (l == r) { tree[rt] = arr[l]; lazy[rt] = 0; return; }
    int m = (l + r) >> 1;
    build(lchild); build(rchild);
    push_up(rt);
}
void update(int L, int R, int64 delta, int rt = 1, int l = 1, int r = n) {
    if (L <= l && r <= R) {
        tree[rt] += delta;
        lazy[rt] += delta;
        return;
    }
    if (lazy[rt]) push_down(rt, r - l + 1);
    int m = (l + r) >> 1;
    if (L <= m) update(L, R, delta, lchild);
    if (R > m)  update(L, R, delta, rchild);
    push_up(rt);
}
int64 query(int L, int R, int rt = 1, int l = 1, int r = n) {
    if (L <= l && r <= R) return tree[rt];
    if (lazy[rt]) push_down(rt, r - l + 1);
    int m = (l + r) >> 1;
    int64 ret = INF;
    if (L <= m) ret = min(ret, query(L, R, lchild));
    if (R > m)  ret = min(ret, query(L, R, rchild));
    return ret;
}


void run() {
    cin >> n >> k;
    for(int i=1;i<=n;i++) cin >> arr[i];
    build();
    while(k--) {
        for(int i=1;i<=n;i++) {
            int64 l = max(1ll,i-arr[i]), r = min(n,i+arr[i]);
            update(l,r,1);
        }
        int64 low = INF;
        for(int i=1;i<=n;i++) {
            arr[i] = query(i,i) - arr[i];
            low = min(low,arr[i]);
        }
        build();
        if(low>=n) break;
    }
    for(int i=1;i<=n;i++) {
        cout << min(arr[i],n) << " ";
    }
    cout << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

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

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

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

const int limit = 50;
int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
  visited[v] = true;
  REP(i,n) {
    if(!graph[v][i]) continue;
    if(visited[i]) continue;
    dfs(i);
  }
}

/***** MAIN *****/
signed main() {
  cin >> n >> m;
  REP(i,m) {
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans = 0;
  REP(i,m) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    REP(j,n) visited[j] = false;
    dfs(0);
    REP(i,n) {
      if(!visited[i]) {
        ++ans;
        break;
      }
    }
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}
/***** MAIN *****/


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

static const int MAX = 1e3;
const int INF = 1e9;
bool visited[MAX][MAX];
int d[MAX][MAX];

int main(){
    int h, w;
    int ch, cw, dh, dw;
    cin >> h >> w;
    cin >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        for(int j = 0; j < w; j++){
            visited[i][j] = (s[j] == '#');
            d[i][j] = INF;
        }
    }
    deque<tuple<int, int, int>> deq;
    deq.emplace_front(ch, cw, 0);
    d[ch][cw] = 0;
    while(!deq.empty()){
        int uh = get<0>(deq.front());
        int uw = get<1>(deq.front());
        int ucost = get<2>(deq.front());
        deq.pop_front();
        visited[uh][uw] = true;
        if(d[uh][uw] < ucost) continue;
        auto check = [&](int i, int j, bool c){
            if(i < 0 || h <= i) return;
            if(j < 0 || w <= j) return;
            if(visited[i][j]) return;
            if(d[i][j] > d[uh][uw] + c){
                d[i][j] = d[uh][uw] + c;
                if(c){
                    deq.emplace_back(i, j, ucost+1);
                } else {
                    deq.emplace_front(i, j, ucost);
                }
            }
        };
        check(uh+1, uw, 0);
        check(uh, uw+1, 0);
        check(uh-1, uw, 0);
        check(uh, uw-1, 0);
        for(int i = uh-2; i <= uh+2; i++){
            for(int j = uw-2; j <= uw+2; j++){
                if(i == uh && j == uw) continue;
                check(i, j, 1);
            }
        }
    }
    cout << (d[dh][dw] == INF ? -1 : d[dh][dw]) << endl;
    return 0;
}

Measured memory_bytes: 8600
def main():
    A, B, C, D = input()
    for i in range(2**3):
        op = ['+', '+', '+']
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break
if __name__  == '__main__':
    main()

Measured memory_bytes: 9144
import java.util.Scanner;
import java.io.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		//int a = Integer.MAX_VALUE;
		int max =Math.max(X, Y);
		long temp;
		long money = A*X + B*Y;
		//System.out.println(money);
		for(int i = 1;i <= max;i++){
			if(Y <= i) Y = i;
			if(X <= i) X = i;
			temp = A*(X-i) + B*(Y-i) + 2*C*i;
			//System.out.println(temp);
			if(money > temp) money = temp;
			//System.out.println(i);
		}

		System.out.println(money);
		//System.out.println(a);
	}
}

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

int main(){
	int N,sum=0;
	cin>>N;
	int L[N];
	for(int i=0;i<N;i++){
		cin>>L[i];
	}
	sort(L,L+N);
	for(int i=0;i<N-1;i++){
		sum+=L[i];
	}
	if(L[N-1]<sum){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int A[7] = {1,3,5,7,8,10,12};
	int B[4] = {4,6,9,11};
	int C = 2;
	int x, y, xa, ya, i;
	scanf("%d%d",&x,&y);
	for(i = 0 ;i < 7; i++){
		if(A[i] == x) xa = 0;
		if(A[i]==y) ya = 0;
	}
	for(i = 0 ;i < 4; i++){
		if(B[i] == x) xa = 1;
		if(B[i]==y) ya = 1;
	}if(C == x)xa = 2;
	if(C == y) ya = 2;

	if(xa==ya)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

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

void solve(int x,int y){
	t[y][x] = '0';

	for(int i=0;i<4;i++){
		for(int j=1;j<=3;j++){
			int nx = x + j * dx[i];
			int ny = y + j * dy[i];

			if(nx>=0 && nx<8 && ny>=0 && ny<8 && t[ny][nx] == '1'){
				solve(nx,ny);
			}
		}
	}
}

int main(void){
	int n;

	cin>>n;

	for(int set=1;set<=n;set++){
		for(int i=0;i<8;i++){
			cin>>t[i];
		}

		int x,y;
		cin>>x>>y;
		solve(x-1,y-1);
		cout<<"Data "<<set<<":\n";
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cout<<t[i][j];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> ans;
	ll n,l;
	cin>>n>>l;
	vector<ll> a(n);
	FOR(i,0,n){
		cin>>a[i];
	}
	bool ok=false;
	ll fini;
	FOR(i,1,n){
		if(a[i]+a[i-1]>=l){
			ok=true;
			fini = i;
		}
	}
	if(not ok){
		cout<<"Impossible"<<endl;
		return 0;
	}
	ans.push_back(fini);
	FORR(i,1,fini)ans.push_back(i);
	FOR(i,fini+1,n)ans.push_back(i);
	reverse(ans.begin(),ans.end());
	cout<<"Possible"<<endl;
	FOR(i,0,ans.size())cout<<ans[i]<<endl;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int x=s.length();
    long long int sum=0;
    for(int i=0;i<x;i++)
    {
        sum=sum+(s[i]-'0');
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3720
# coding:utf-8

import sys
import heapq
# from collections import defaultdict, deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, c = LI()
tv = [tuple(LI()) for _ in range(n)]

used = [[0] * (10 ** 5 + 1) for _ in range(c)]
for s, t, channel in tv:
    used[channel - 1][s:t + 1] = [1] * (t - s + 1)

ans = 0
for col in zip(*used):
    ans = max(ans, sum(col))

print(ans)


Measured memory_bytes: 41016
N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K-Q]*N

for i in range(Q):
    who_answered[i] = int(input()) - 1
    participants[who_answered[i]] += 1

for i in range(N):
    if participants[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10416
@line = split(/ /, <>);
my $a = $line[0];
chomp(my $b = $line[1]);
my $ans = 0;
if ($a eq 'D') { $ans = 1 - $ans; }
if ($b eq 'D') { $ans = 1 - $ans; }
print substr("HD", $ans, 1)."\n";

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,ami=0;
    cin>>n;
    long long int a[n+2];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=1;i<n-1;i++) {
        if( ( a[i]>a[i-1] && a[i+1]>a[i] ) || ( a[i]<a[i-1] && a[i+1]<a[i]  )  )
            ami++;
    }


    cout<<ami<<endl;

    return 0;
}


Measured memory_bytes: 256
// TAKOYAKI FESTIVAL 2019

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int N;
    int d[50];
    cin >> N;

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

    int sum = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            int tmp = d[i] * d[j];
            sum += tmp;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int h,n;
    cin>>h>>n;
    vector< int> a(n),b(n);
    int maxa=0;
    rep(i,n){
        cin >>a[i]>>b[i];
        maxa=max(maxa,a[i]);
    } 
    //dp[i] = モンスターの体力をh減らすために必要な魔力の最小値
    int64_t dp[100000]={};
    for(int i=1;i<100000;i++){
        dp[i]=1e13;
    }
    for(int i=1;i<=h+maxa;i++){
        rep(j,n){
            if(i-a[j]>=0){
                dp[i] = min(dp[i],dp[i-a[j]]+b[j]);
            }
        }
    }

    /*
    rep(i,h+maxa){
        cout<<"dp["<<i<<"]="<<dp[i]<<endl;
    }
    */
    int64_t ans=1e15;
    for(int i=h;i<h+maxa;i++){
        //cout<<"dp["<<i<<"]="<<dp[i]<<endl;
        ans = min(ans,dp[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int H, N;
char map[20][2][2];
char block[3][2][2][2];

int dfs(int next, char map[20][2][2])
{
	char map2[20][2][2];
	char blk[2][2][2];
	int nx, ny;
	
	if(next == N) return 0;
	
	int ret = 0;
	for(int dx = -1; dx <= 1; dx++){
		for(int dy = -1; dy <= 1; dy++){
			
			bool flag = true;
			for(int z = 0; z < 2; z++){
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						if(block[next][z][x][y] == '.') continue;
						nx = x + dx, ny = y + dy;
						if(nx < 0 || nx >= 2 || ny < 0 || ny >= 2){
							flag = false;
							goto PASS;
						}
					}
				}
			}
			PASS:;
			if(!flag) continue;
			
			for(int z = 0; z < 20; z++){
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						map2[z][x][y] = map[z][x][y];
					}
				}
			}
			for(int z = 0; z < 2; z++){
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						blk[z][x][y] = '.';
						nx = x - dx, ny = y - dy;
						if(nx < 0 || nx >= 2 || ny < 0 || ny >= 2) continue;
						blk[z][x][y] = block[next][z][nx][ny];
					}
				}
			}
			
			int h1, h2, h = -1;
			for(int x = 0; x < 2; x++){
				for(int y = 0; y < 2; y++){
					h1 = -1;
					for(int z = 0; z < 20; z++) if(map[z][x][y] == '#') h1 = z;
					h2 = 0;
					for(int z = 0; z < 2; z++){
						if(blk[z][x][y] == '.') h2++;
						else break;
						if(z == 1) h2 = 20;
					}
					h = max(h, h1-h2+1);
				}
			}
			
			for(int z = 0; z < 2; z++){
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						if(h+z < 0) continue;
						if(blk[z][x][y] == '#') map2[h+z][x][y] = blk[z][x][y];
					}
				}
			}
			
			
			int cnt = 0;
			for(int z = 0; z < 20; z++){
				flag = true;
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						if(map2[z][x][y] == '.'){
							flag = false;
							goto PASS2;
						}
					}
				}
				PASS2:;
				if(!flag) continue;
				
				cnt++;
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						map2[z][x][y] = '.';
					}
				}
				for(int ez = z; ez < 19; ez++){
					for(int x = 0; x < 2; x++){
						for(int y = 0; y < 2; y++){
							map2[ez][x][y] = map2[ez+1][x][y];
						}
					}
				}
				z--;
			}
			
			ret = max(ret, cnt + dfs(next+1, map2));
		}
	}
	
	return ret;
}

int main(void)
{
	while(1){
		cin >> H >> N;
		if(H == 0 && N == 0) break;
		
		for(int i = 0; i < 20; i++){
			for(int x = 0; x < 2; x++){
				for(int y = 0; y < 2; y++){
					map[i][x][y] = '.';
				}
			}
		}
		for(int i = 0; i < H; i++){
			for(int x = 0; x < 2; x++){
				for(int y = 0; y < 2; y++){
					cin >> map[i][x][y];
				}
			}
		}
		
		for(int i = 0; i < N; i++){
			for(int z = 0; z < 2; z++){
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						cin >> block[i][z][x][y];
					}
				}
			}
		}
		
		cout << dfs(0, map) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2968