akhauriyash/Code-Regression huggingface dataset:
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  int n, t;
  cin >> n >> t;
  int p[50];
  rep(i, n) cin >> p[i];
  ll dp[51][2] = {};
  dp[0][0] = 1;
  rep(i, n)
  {
    rep(j, 2)
    {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][(j + p[i]) % 2] += dp[i][j];
    }
  }
  cout << dp[n][t] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int rt = 0;
  int x;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x<=K/2){
    rt+=(2*x);}
    else{rt+=2*(K-x);}
  }
 cout << rt << endl;
}

Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<algorithm>
#define pi acos(-1.0)
using namespace std;
 
int main(){
    double r;
    while(cin>>r ){
 
        cout<<setprecision(6)<<fixed<<pi*r*r<<" "<<setprecision(6)<<fixed<<2*pi*r<<endl;
    }
    return 0;
}

Measured memory_bytes: 3244
//AOJ0118
/*样本输入
10 10
#### ***** @
@＃@ @ @ @ @ ####
@ ## *** @@@ *
＃****＃* @ **
## @ *＃@ @ * ##
* @ @ @ @ @ @ @ @ @ @ @＃
***＃@ * @ ## *
* @ @ @ @ @ @ @ @ @ ## @
* @ *＃* @ ## **
@ ****＃@ @＃@
0 0
样本输入的输出
33*/
#include <iostream>
using namespace std;
int n,m;
char map[100][100];
const int der[4][2]={
	{0,-1},
	{1,0},
	{0,1},
	{-1,0},
};
void dfs(const int& x,const int& y,const char cnm){
	map[x][y]='x';
	for(int i=0;i<4;i++){
			int xx=x+der[i][1];
			int yy=y+der[i][0];
			if(0<=xx&&xx<n&&0<=yy&&yy<m&&map[xx][yy]==cnm){
				dfs(xx,yy,cnm);
			}	
		}
}
int main(){
	ios::sync_with_stdio(false);
	while(cin>>n>>m,m>0){
		int ans=0;
		int j,i;
	for( i=0;i<n;i++){
		for( j=0;j<m;j++){
			cin>>map[i][j];
		}
	}
	for( i=0;i<n;i++){
		for( j=0;j<m;j++){
			if(map[i][j]!='x'){
				dfs(i,j,map[i][j]);
				++ans;
			}
		}
	}
	cout<<ans<<endl;
}
return 0;
}


Measured memory_bytes: 3896
n = int(input())
s_common = list(input())
s_common_pre = ""
for i in range(n-1):
    s = list(input())
    s_common_pre = s_common.copy()
    len_common = len(s_common_pre)
    for i in range(len_common):
        if s_common_pre[i] in s:
            s.remove(s_common_pre[i])
        else:
            s_common.remove(s_common_pre[i])

s_common.sort()
s_common = "".join(s_common)
print(s_common)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      String num1, num2, num3, num4,num5;
      int ans,t1, t2, t3, t4,t5;
      ans = 0;
      for(;b>=a;a++){
        String s = String.valueOf(a);
        num1 = s.substring(0,1);
        num2 = s.substring(1,2);
        num3 = s.substring(2,3);
        num4 = s.substring(3,4);
        num5 = s.substring(4,5);
        t1 = Integer.parseInt(num1);
        t2 = Integer.parseInt(num2);
        t3 = Integer.parseInt(num3);
        t4 = Integer.parseInt(num4);
        t5 = Integer.parseInt(num5);
        if(t1 == t5 && t2 == t4){
          ans = ans+1;
        }
      }
		  System.out.println(ans);
   }
 }


Measured memory_bytes: 38100
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.IO
import qualified Data.Vector.Unboxed.Mutable as UM

main = do
  [h,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- h, w <= 400
  ss <- V.replicateM h BS.getLine
  -- forall s in ss. BS.length s == w
  arr <- newArray ((0,0),(h-1,w-1)) (-1) :: IO (IOUArray (Int,Int) Int8)
  !black_and_white <- UM.new 2 :: IO (UM.IOVector Int)
  let search :: Int -> Int -> Int -> Int -> IO Int
      search !acc !k !i !j
        | i >= h = return acc
        | j >= w = search acc k (i+1) 0
        | otherwise = do
            v <- readArray arr (i,j)
            UM.write black_and_white 0 0
            UM.write black_and_white 1 0
            when (v == -1) $
              if (ss V.! i) `BS.index` j == '#'
              then search_black k i j -- black
              else search_white k i j
            nb <- UM.read black_and_white 0
            nw <- UM.read black_and_white 1
            search (acc + nb * nw) (k+1) i (j+1)
      search_black :: Int -> Int -> Int -> IO ()
      search_black !k !i !j
        | i < 0 || j < 0 || i >= h || j >= w = return ()
        | (ss V.! i) `BS.index` j == '#' = do
            v <- readArray arr (i,j)
            when (v == -1) $ do
              writeArray arr (i,j) 1
              UM.modify black_and_white (+1) 0
              search_white k (i-1) j
              search_white k i (j-1)
              search_white k (i+1) j
              search_white k i (j+1)
        | otherwise = return ()
      search_white :: Int -> Int -> Int -> IO ()
      search_white !k !i !j
        | i < 0 || j < 0 || i >= h || j >= w = return ()
        | (ss V.! i) `BS.index` j == '.' = do
            v <- readArray arr (i,j)
            when (v == -1) $ do
              writeArray arr (i,j) 1
              UM.modify black_and_white (+1) 1
              search_black k (i-1) j
              search_black k i (j-1)
              search_black k (i+1) j
              search_black k i (j+1)
        | otherwise = return ()
  result <- search 0 0 0 0
  {-
  arr' <- freeze arr :: IO (UArray (Int,Int) Int)
  forM_ [0..h-1] $ \i -> do
    print [arr' ! (i,j) | j <- [0..w-1]]
  -}
  print result


Measured memory_bytes: 7548
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

vector<pair<ll, ll>> PrimeFactorization(ll n) {
    vector<pair<ll, ll>> f;
    for (ll i = 2; i * i <= n; i++) {
        ll cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) f.push_back(make_pair(i, cnt));
    }
    if (n != 1) f.push_back(make_pair(n, 1));
    return f;
}

int main() {
    ll N, P; cin >> N >> P;
    vector<pair<ll, ll>> factors = PrimeFactorization(P);

    ll ans = 1;
    for (auto f : factors) {
        if (f.second >= N) {
            ans *= pow(f.first, f.second / N);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y>0:
    x,y=y,x%y
  return x
b=[a[0]]
for i in range(1,n-1):
  b.append(gcd(b[-1],a[i]))
c=[a[n-1]]
for i in range(1,n-1):
  c.append(gcd(c[-1],a[n-1-i]))
q=b[n-2]
for i in range(0,n-2):
  p=gcd(b[i],c[n-3-i])
  q=max(p,q)
print(max(q,c[n-2]))

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
public:
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
	int n;
	cin>>n;
	P r[110],b[110];
	rep(i,n){
		cin>>r[i].first>>r[i].second;
	}
	rep(i,n){
		cin>>b[i].first>>b[i].second;
	}
	sort(b,b+n);
	int ans=0;
	rep(i,n){
		vector<P> p;
		rep(j,n){
			if(b[i].first>r[j].first&&b[i].second>r[j].second)p.push_back(P(r[j].second,j));
		}
		sort(p.begin(),p.end(),greater<P>());
		if(p.size()>0){
			b[i].first=-10;
			r[p[0].second].first=INF;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

const int INF = 1000000000;
const int MAX_N = 100000 + 10;
int dp[MAX_N];
int h[MAX_N];

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

  int N;
  cin >> N;

  for (int i = 0; i < N; i++) cin >> h[i];
  
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    int jp1, jp2;
    jp1 = dp[i-1] + abs(h[i] - h[i-1]);

    if (i >= 2) jp2 = dp[i-2] + abs(h[i] - h[i-2]);
    else jp2 = INF;
	   
    dp[i] = min(jp1, jp2);
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 3932
n = int(input())
a, b = map(int, input().split())
pli = list(map(int, input().split()))

one = [p for p in pli if p<=a]
two = [p for p in pli if (a+1)<=p<=b]
the = [p for p in pli if (b+1)<=p]

print(min([len(one), len(two), len(the)]))


Measured memory_bytes: 3060
N,K=map(int,input().split())
MOD=10**9+7

def calc(a):
  smallest=(a-1)*a//2
  largest=(2*N-a+1)*a//2
  return largest-smallest+1

ans=0
for i in range(K,N+2):
  ans+=calc(i)
ans%=MOD  
print(ans)

Measured memory_bytes: 9196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int N = in.nextInt();
        	if(N == 1) {
        		out.println("Hello World");
        	}else{
            	int A = in.nextInt();
            	int B = in.nextInt();
        		out.println(A + B);
        	}
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>

using namespace std;

long long int f(int n){
	static long long int dp[3000];
	for(int i=0;i<=n;i++){
	if(i==0) dp[i] = 2;
	else if(i==1) dp[i] = 1;
	else dp[i] = dp[i-1] + dp[i-2];
	}
	return dp[n];
}
int main(){
	int n;
	cin>>n;
	cout<<f(n)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#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 LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;

using namespace std;


int main(int argc, char* argv[])
{
    int n,k;
    scanf("%d%d", &n, &k);

    double ans=0.0;
    if(n>=k) {
        ans = (double)(n-k+1)/n;
    }

    int aa=2;
    int curr=k;
    while(1) {
        int next=(k%aa==0? k/aa: k/aa+1);
        {
            if(next<=n) {
                int curr0 = MIN(n+1,curr);
                int next0 = next;
                double add = (double)(curr0-next0)/n/aa;
                ans+=add;
            }
        }
        if(next<=1) break;
        curr=next;
        aa*=2;
    }
    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	double x[4];
	double y[4];
	char c;

	while(cin >> x[0] >> c >> y[0]){
		for(int i=1;i<4;i++){
			cin >> c >> x[i] >> c >> y[i];
		}
		bool flag1 = 0;
		bool flag2 = 0;
		
		for(int i=0;i<4;i++){
			if((x[(i+2)%4]-x[i%4])*(y[(i+1)%4]-y[i%4])-(y[(i+2)%4]-y[i%4])*(x[(i+1)%4]-x[i%4])>0){
				flag1=1;
			}
			else{
				flag2=1;
			}
		}

		if(flag1 && flag2){
			cout << "NO" << endl;
		}
		else if(flag1 || flag2){
			cout << "YES" <<endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#define orz 1000000007
using namespace std;
long long n,k;
bool vis[100005];//dfs
vector<int> mp[100005];
queue<int> q;

long long inv[100005]={1,1},fact[100005]={1,1},f[100005]={1,1};

void init()
{//快速计算阶乘的逆元
    int i;
    for(i=2;i<=k;i++){
        fact[i]=fact[i-1]*i%orz;
        f[i]=(orz-orz/i)*f[orz%i]%orz;
        inv[i]=inv[i-1]*f[i]%orz;
    }
}



long long bfs(){
    int i,cur,v;
    long long cnt,ans=1;
    vis[1]=true;
    for(i=0;i<mp[1].size();i++){
        v=mp[1][i];
        q.push(v);
        vis[v]=true;
    }
    cnt=mp[1].size();
    ans=(fact[k]*inv[k-cnt-1])%orz;
    while(!q.empty()){
        cur=q.front();q.pop();
        for(i=0,cnt=0;i<mp[cur].size();i++){
            v=mp[cur][i];
            if(!vis[v]){
                q.push(v);
                vis[v]=true;
                cnt++;
            }
        }
        if(k-2<cnt) return 0;//没有涂色方案 颜色不够
        if(cnt==0) continue;
        ans*=(fact[k-2]*inv[k-2-cnt])%orz;
        ans%=orz;
    }

    return ans;
}

int main(){
    int u,v,maxcnt=0,i;
    scanf("%lld%lld",&n,&k);
    for(i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        mp[u].push_back(v);
        mp[v].push_back(u);
    }
    init();
    printf("%lld",bfs());
    return 0;
}


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

namespace abcreftgh
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int[] abc = new int[26];
            for(int i = 0; i < 26;i++)
            {
                abc[i] = 0;
            }
            int ans = 0;
            for(int i = 0; i < str.Length;i++)
            {
                int temp = (int)str[i] - (int)'a';
                if (abc[temp] == 1)
                {
                    ans = 1;
                    break;
                }else
                {
                    abc[temp] = 1;
                }
            }
            if (ans == 1)
            {
                Console.WriteLine("no");
            }else
            {
                Console.WriteLine("yes");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


vector<string> field(55);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll H, W;

ll bfs(){
  Vs fi = field;
  int d[55][55];
  rep(i, 0, 55) rep(j, 0, 55) d[i][j] = -1;
  d[0][0] = 0;
  queue<pair<int, int>> qu;
  qu.push(make_pair(0, 0));
  while(!qu.empty()){
    pair<int, int> u = qu.front(); qu.pop();
    fi[u.first][u.second] = '#';
    rep(i, 0, 4){
      int y = u.first+dy[i], x = u.second+dx[i];
      if(y<0 || y>=H || x<0 || x>=W) continue;
      if(fi[y][x] == '#') continue;
      d[y][x] = d[u.first][u.second] + 1;
      fi[y][x] = '#';
      qu.push(make_pair(y, x));
    }
  }
  if(d[H-1][W-1] == -1){
    cout << -1 << endl;
    return -1;
  }
  return d[H-1][W-1];
}

int main() {
  cin >> H >> W;
  rep(i, 0, H){
    cin >> field[i];
  }

  ll white = 0;
  rep(i, 0, H) rep(j, 0, W) if(field[i][j] == '.') white++;

  ll m = bfs();
  if(m == -1) return 0;
  cout << white - m -1 << endl;

  return 0;
}


Measured memory_bytes: 256
from bisect import bisect

n = 10000000
sn = int(n**0.5)+1

num = [False, False] + [True]*(n-1)
for i in xrange(2, int(n**0.5)+1):
  if num[i]:
    for j in xrange(i**2, n, i):
      num[j] = False
prime = [i for i in xrange(2, n) if num[i]]

while True:
  try:
    print bisect(prime, input())
  except:
    break

Measured memory_bytes: 160512
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 100002;

int n, st;
string S[2];
long long ats;

int main(){
    scanf("%d", &n);
    cin >> S[0];
    cin >> S[1];
    if (S[0][0] == S[0][1]){
        st = 2;
        ats = 6;
    }
    else {
        st = 1;
        ats = 3;
    }
    while (st < n) {
        if (S[0][st] == S[1][st]) {
            if (S[0][st-1] == S[1][st-1]) {
                ats *= (long long)2;
            }
            st++;
        } else {
            if (S[0][st-1] == S[1][st-1]) {
                ats *= (long long)2;
            } else {
                ats *= (long long)3;
            }
            st += 2;
        }

        ats %= 1000000007;
    }

    cout << ats << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,s,w,q;
vi a;

int main(){
	while(1){
		cin>>n>>s>>w>>q;
		if(!n) break;
		a=vi(n);
		for(int i=0;i<n;i++){
			a[i]=(s/7)%10;
			if(s%2==0) s/=2;
			else s=(s/2)^w;
		}
		ll res=0;
		if(q==2||q==5){
			ll x=0;
			for(int i=0;i<n;i++){
				if(a[i]!=0) x++;
				if(a[i]%q==0) res+=x;
			}
		}
		else{
			map<int,ll> m;
			int X=1;
			vi b(n+1);
			for(int i=n-1;i>=0;i--){
				b[i]=(b[i+1]+X*a[i])%q;
				(X*=10)%=q;
			}
			for(int i=0;i<=n;i++){
				res+=m[b[i]];
				if(i==n||a[i]!=0) m[b[i]]++;
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, Z, W;
	cin >> N >> Z >> W;
	int a[N+10];
	for(int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	a[0] = W;
	cout << max(abs(W-a[N]), abs(a[N]-a[N-1])) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ABS(x)		((x)<0 ? -(x):(x))
typedef long long ll;
int main(){
    ll n, sum=0, a[200000]={0};
    scanf("%lld",&n);
    scanf("%lld", &a[0]);
    for(int i=1; i<n; i++){
        scanf("%lld", &a[i]);
        if( a[i] - a[i-1] < 0 ){
            sum += ABS(a[i] - a[i-1]);
            a[i] = a[i-1];
        }
    }
    printf("%lld\n", sum);
    return 0;
}

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

double n,m;
int d;

signed main(){
    cin>>n>>m>>d;
    m--;
    double res=m/n;
    cout<<setprecision(20)<<(d==0?res:res*2.0*(n-d)/n)<<endl;
}

Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    AB = [tuple(map(int, input().split())) for _ in range(n)]
    AB = sorted(AB, key=lambda x: x[0])
    num = 0
    ans = 0
    for a, b in AB:
        w_num = m - num
        if w_num <= b:
            num += w_num
            ans += w_num * a
            break
        else:
            num += b
            ans += b * a
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24548
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,-1,1,1,-1};
int dy[]={0,1,0,-1,-1,-1,1,1};


int main(){
    int n,k;cin >> n >> k;
    vector<LL> a(n);
    int cnt = 0;
    vector<LL> p,m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] == 0){
            cnt++;
        }
        else if(a[i] > 0){
            p.pb(a[i]);
        }
        else{
            m.pb(-a[i]);
        }
    }
    if(n - k < cnt){
        cout << 0 << endl;
    }
    else if(m.size() == n){
        LL ans = 1;
        if(k % 2){
            sort(ALL(m));
            for (int i = 0; i < k; i++) {
                ans = ans * m[i]%mod;
            }
            ans = (mod - ans)%mod;
        }
        else{
            sort(RALL(m));
            for (int i = 0; i < k; i++) {
                ans = ans * m[i]%mod;
            }
        }
        cout << ans << endl;
    }
    else{
        int np = p.size(), nm = m.size();
        int am,ap;
        long double s = -1;
        vector<long double> pcum(np + 1, 0);
        sort(RALL(p));
        for (int i = 0; i < np; i++) {
            pcum[i + 1] = pcum[i] + logl(p[i]);
        }
        sort(RALL(m));
        vector<long double> mcum(nm + 1, 0);
        for (int i = 0; i < nm; i++) {
            mcum[i + 1] = mcum[i] + logl(m[i]);
        }
        for (int i = 0; i <= min(nm, k); i+=2) {
            long double d = mcum[i];
            int res = k - i;
            if(res <= np){
                d += pcum[res];
                if(chmax(s, d)){
                    ap = res;
                    am = i;
                }
            }
        }
        if(s == -1){
            if(cnt){
                cout << 0 << endl;
            }
            else{
                LL ans = 1;
                for (int i = 0; i < np; i++) {
                    ans = ans * p[i]%mod;
                }
                for (int i = 0; i < nm; i++) {
                    ans = ans * m[i]%mod;
                }
                ans = (mod - ans)%mod;
                cout << ans << endl;
            }
        }
        else{
            LL ans = 1;
            for (int i = 0; i < ap; i++) {
                ans = ans * p[i]%mod;
            }
            for (int i = 0; i < am; i++) {
                ans = ans * m[i]%mod;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


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


int begin( char *base ,char *old ,int oldLen ,int now )
{
	int i ;
	for( i = now ; i < oldLen ; ++i )
	{
		if( base[ 0 ] == old[ i ] )
		{
			return i ;
		}
	}

	return oldLen ;
}

int pair( char *base ,int baseLen ,char *old ,int oldLen ,int start )
{
	int baseP ;

	int i ,j ,k ;
	while( start < oldLen )
	{
		for( i = 1 ; ( i * ( baseLen - 1 ) ) <= oldLen ; ++i )
		{
			baseP = 0 ;
			for( j = start ; baseP < baseLen && j < oldLen ; j += i )
			{
				if( base[ baseP ] != old[ j ] )
				{
					break ;
				}

				++baseP ;
			}

			if( baseP == baseLen )
			{
				return 1 ;
			}
		}

		start = begin( base ,old ,start + 1 ,oldLen ) ;
	}

	return 0 ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	char base[ 128 ] ;
	scanf( "%s" ,base ) ;

	int baseLen = strlen( base ) ;

	int baseP ;
	int ans = 0 ;

	int i ,j ,k ,t ;
	for( i = 0 ; i < N ; ++i )
	{
		char old[ 128 ] ;
		scanf( "%s" ,old ) ;

		int oldLen = strlen( old ) ;

		if( oldLen >= baseLen && pair( base ,baseLen ,old ,oldLen ,begin( base ,old ,oldLen ,0 ) ) == 1 )
		{
			++ans ;
		}
	}

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


	return 0 ;
}

Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
typedef long long ll;

int main(){
  stack<int> s1;
  stack<pii> s2;

  char ch;
  for(int i=0; cin >> ch; i++){
    if(ch == '\\') s1.push(i);
    else if(ch == '/' && !s1.empty()){
      int j = s1.top(); s1.pop();
      int a = i-j;
      while(!s2.empty() && j < s2.top().first){
        a += s2.top().second; s2.pop();
      }
      s2.push(mp(j, a));
    }
  }

  int sum = 0;
  stack<int> s3;
  while(!s2.empty()){
    int tmp = s2.top().second; s2.pop();
    s3.push(tmp);
    sum += tmp;
  }

  cout << sum << endl;
  cout << s3.size();
  while(!s3.empty()){
    cout << " ";
    cout << s3.top();
    s3.pop();
  }
  cout << endl;

  return 0;
}




Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;

bool is(int x){
    for(int i = 2; i <= sqrt(x); i++){
        if(x % i == 0) return false;
    }
    return true;
}

void solve(){
    int x;
    cin >> x;
    for(int i = x; i <= 1e6; i++){
        if(is(i)){
            cout << i;
            return;
        }
    }
}

 
int main(){
    barsik;
    //freopen("file.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(ll i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int64_t> v(N);
  for(int i=0;i<N;i++){
    cin>>v.at(i);
  }
  vector<int64_t> memo(N);
  int64_t c=0;
  int64_t d=0;
  while(memo.at(d)==0){
    c++;
    memo.at(d)=c;
    d=v.at(d)-1;
  }
  int64_t r=memo.at(d)-1;
  int64_t mod=c-r;
  int64_t ans=0;
  if(K<=r){
    ans=K+1;
  }
  else{
    ans=(K-r)%mod+r+1;
  }
  int64_t z=0;
  while(memo.at(z)!=ans){
    z++;
  }
  cout<<z+1;
}

Measured memory_bytes: 6428
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0;
		for(int i = 0; i < n; i++){
			if(judge(sc.nextInt())) cnt++;
		}
		System.out.println(cnt);
	}
	static boolean judge(int tmp){
		if(tmp==2 || tmp==3 || tmp==5 || tmp==7) return true;
		if(tmp % 2 == 0) return false;
		for(int i = 3; i <= Math.sqrt(tmp); i++){
			if(tmp % i == 0) return false;
		}
		return true;
	}
}

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))

typedef long long ll;

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

    int h,w;
    cin>>h>>w;
    char a[105];
    for(int i=1;i<=h;++i){
        cin>>a;
        cout<<a<<endl;
        cout<<a<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int H, A;
	scanf("%d %d", &H, &A);
	if(H%A == 0){
		printf("%d\n", (H/A));
	}else{
		printf("%d\n", (H/A)+1);
	}
	
	
	return 0;
}


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	string s; cin >> s;
	reverse(all(s));
	cout << s << endl;
}


Measured memory_bytes: 3176
import math

while True:
    a, op , b = input().split()
    
    if op == "+":
        result = int(a) + int(b)
    elif op == "-":
        result = int(a) - int(b)
    elif op == "*":
        result = int(a) * int(b)
    elif op == "/":
        result = math.floor(int(a) / int(b))
    elif op == "?":
        break;

    print(result)


Measured memory_bytes: 5664
import numpy as np
import math

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

#最後に注文するものだけに依存する
X=np.zeros(5)
X[0]=a
X[1]=b
X[2]=c
X[3]=d
X[4]=e

Y=np.zeros(5)
for i in range(5):
  Y[i]=math.ceil(X[i]/10)*10

Z=np.zeros(5)
for i in range(5):
  Z[i]=np.sum(Y)-Y[i]+X[i]

print(int(min(Z)))

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

typedef long long ll;

int main(){
  ll n;cin>>n;
  ll ans=1e18;
 	for(ll i=1;i<=sqrt(n);i++){
    if(n%i!=0) continue;
    ll j=n/i;
    ans=min(ans,i+j-2);
  }
  cout<<ans<<endl;
}


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

#ifdef local
template <class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template <class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); cerr << ", "; _E(x.second); cerr << ")"; } template <class T> void _E(vector<T> x) { cerr << "["; for (auto it = x.begin(); it != x.end(); ++it) { if (it != x.begin()) cerr << ", "; _E(*it); } cerr << "]"; }
void ERR() {} template <class A, class... B> void ERR(A x, B... y) { _E(x); cerr << (sizeof...(y) ? ", " : " "); ERR(y...); }
#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif

using ll = long long;


int main(int argc, char *argv[]) {
  cin.sync_with_stdio(false), cin.tie(nullptr);

  int x;
  cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << "\n";
}



Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef map<ll, ll> Map;

ll gcd(ll a, ll b) {
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(void) {
    ll N, M;
    cin >> N >> M;
    string s, t;
    cin >> s >> t;
    map<ll, char> mp;
    ll L=N*M/gcd(N, M);
    ll i;
    
    for(i=1; i<=N; i++) {
        mp[(i-1)*L/N+1]=s[i-1];
    }
    
    for(i=1; i<=M; i++) {
        auto it=mp.find((i-1)*L/M+1);
        if(it!=mp.end()) {
            if(t[i-1]!=it->second) {
                prin(-1);
                return 0;
            }
        }
    }
    
    prin(L);
}

Measured memory_bytes: 6144
import java.util.Arrays;
import java.util.Scanner;

public class Main 
{
	static long[] mask = new long[40];

	static long powmask(long ma)
	{
		for(int i = 0; i < 40; i++)
			if(mask[i] == ma)return i;
		
		return -1;
	}
	
	public static void main(String[] args) 
	{
		long curm = 1;
		for(int i = 0; i < 40; i++)
		{
			mask[i] = curm;
			curm *= 2;
		}
		//30
		//max 39 digits for sum
//		System.out.println(Long.toString(1000000000l,2));
//		System.out.println(Long.toString(1000000000000l,2));
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		long[] a = new long[1000];
		long[] suml = new long[n];
		long cursum = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			cursum +=a[i];
			suml[i] = cursum;
		}
		
		int seqs = (n*(n+1))/2;
		int curseqs = 0;
		
		long[] seq = new long[seqs];
		
		
		long an = 0;
		
		for(int i = 0; i < n; i++)
		{
			for(int j = i; j < n; j++)
			{
				long curseq = suml[j];
				if(i>0)curseq-=suml[i-1];
				seq[curseqs]=curseq;
//				System.out.println("b " + seq[curseqs]);
				curseqs++;
			}
		}
		
		long reqs = 0;
		int maxmask = 40;
		while(true)
		{
			long[] occ = new long[40];
			
			for(int i = 0; i < seqs; i++)
			{
				for(int d = 0; d < maxmask; d++)
					if(((mask[d] & seq[i]) > 0 && (reqs == 0 || (reqs & seq[i]) == reqs)))
					{
//						System.out.println("GULP");
						occ[d]++;
					}
					else 
					{
//						System.out.println(Long.toString(mask[d],2) + " and " + Long.toString(seq[i],2));
					}
			}
//			System.out.println("occ: " + Arrays.toString(occ));
			
			int bigd = -1;
			for(int i = 0; i < 40; i++)
			{
				if(occ[i] >= k)
				{
					bigd = i;
				}
			}
			
			if(bigd > -1)
			{
				an += mask[bigd];
				reqs += mask[bigd];
				maxmask = bigd;
			}
			else
			{
				System.out.println(an);
				return;
			}
		}
	}

}


Measured memory_bytes: 30384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1001001001;
const long long MOD = 998244353;
const double EPS = 1e-10;

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

    ll n,k;
    cin>>n>>k;
    ll l[k],r[k];
    for(ll i=0;i<k;i++)cin>>l[i]>>r[i];
    ll imos[202020]={};
    imos[1]=1;
    for(ll i=1;i<n;i++){
        imos[i]+=imos[i-1];
        imos[i]%=MOD;
        for(ll j=0;j<k;j++){
            ll x=i+l[j],y=i+r[j];
            if(x>n)continue;
            y=min(y,n);
            imos[x]+=imos[i];
            imos[x]%=MOD;
            imos[y+1]-=imos[i];
            while(imos[y+1]<0)imos[y+1]+=MOD;
        }
    }
    cout<<(imos[n])%MOD<<endl;
}

Measured memory_bytes: 5224
"use strict";
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);
});
/* 入力は 
3 4
5 6
2 2
0 0
*/
reader.on('close', () => {
    for (var line of lines) {
        var l = line.trim().split(' ').map(Number);
	var h=l[0];
	var w=l[1];

	if (h===0 && w===0) {
	    break;
	}
	//console.log('h: ', h, 'w: ', w )
	console.log(aux(h,w));
    }
});

function aux(h,w)
{
    var l='';
    var s='';
    for (var i=0; i<w; i++) {
	l += '#';
    }
    l += '\n';
    for (var j=0; j<h; j++) {
	s += l;
    }

    //console.log('s: ', s)

    return(s);
}


Measured memory_bytes: 16360
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  int N,M;
  ll temp;
  cin>>N>>M;
  pair<ll,int> p[210000];
  for(int i=0;i<N;i++){
    cin>>p[i].first;
    p[i].second=1;
    p[i].first*=-1;
  }
  for(int i=0;i<M;i++){
    cin>>p[N+i].second>>p[N+i].first;
    p[N+i].first*=-1;
  }
  sort(p,p+M+N);
  ll ans=0;
  int now=0;
  for(int i=0;i<N;i++){
    if(p[now].second!=0){
      p[now].second--;
      ans+=p[now].first*-1;
    }else{
      now++;
      ans+=p[now].first*-1;
      p[now].second--;
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4088
n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
cnt = min(len(A), len(B))
flag = 0
for i in range(cnt):
    if A[i] > B[i]:
        flag = 1
        break
    elif A[i] < B[i]:
        flag = 2
        break
if (flag == 0 and len(A) < len(B)) or flag ==2:
    print(1)
else:
    print(0)


Measured memory_bytes: 5628
let () =
  let n, m, k = Scanf.scanf "%d %d %d" (fun n m k -> n, m, k) in
  begin List.concat @@ Array.to_list @@ Array.init (n + 1) (fun x ->
    Array.to_list @@ Array.init (m + 1) (fun y -> (x, y))) end
  |> List.exists (fun (x, y) -> k = x * m + y * n - 2 * x * y)
  |> (function true -> "Yes" | false -> "No")
  |> print_endline

Measured memory_bytes: 75640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  int cnt = 0;
  int flag = 0;
  for(int i=1; i<N; i++){
    if(a.at(i) > a.at(i-1) && flag == -1){
      cnt++;
      flag = 0;
      continue;
    }
    if(a.at(i) < a.at(i-1) && flag == 1){
      cnt++;
      flag = 0;
      continue;
    }
    if(flag == 0){
      if(a.at(i) > a.at(i-1)){
        flag = 1;
      }
      if(a.at(i) < a.at(i-1)){
        flag = -1;
      }
    }
  }
  cout << cnt+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 5*1e5;


int main(){
    AC
    int n;
    cin>>n;
    n%=1000;
    if(n==0)
        cout<<0<<endl;
    else
        cout<<1000-n<<endl;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

constexpr lli MOD = 1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;
constexpr int tenfive = 100000;


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


	lli ans = LIMIT;
	for (int i = -100; i <= 100; i++) {
		lli sum = 0;
		for (int j = 0; j < N; j++) {
			sum += pow(i - v[j], 2);
		}
		ans = min(ans, sum);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int a[200009];
int tb[200009];

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

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

		if (i > 0) {
			mi = min(mi, a[i-1]);

			tb[i] = mi;
		}
		
	}

	LL ans = -(1<<30);
	for (int i = 1; i < n; i++) {
		LL d = a[i] - tb[i];
		ans = max(ans, d);
	}

	cout << ans << endl;
}


Measured memory_bytes: 4668
require 'prime'
A, B = gets.chomp.split.map(&:to_i)


def gcd(a, b)
  a, b = b, a if a < b

  while b > 0
    a, b = b, a % b
  end
  a
end

def fetch_prime_list(max)
  table = Array.new(max + 1,true)

  (2..max).each do |num|
    if table[num] == true
      k = num * num
      while k <= max
        table[k] = false
        k += num
      end
    end
  end
  return table
end

g = gcd(A, B)
p 1 + g.prime_division.size


Measured memory_bytes: 2172
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	if (a[0] != 0) {
		cout << "-1" << endl;
		return 0;
	}
	int ans = 0;
	for (int i = 1; i < a.size(); ++i) {
		if (a[i] > a[i - 1]) {
			if (a[i] - a[i - 1] != 1) {
				cout << -1 << endl;
				return 0;
			}
			ans++;
		}
		else {
			if (a[i] != 0) {
				ans += a[i];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
from sys import argv

debug = "a" in argv
n = int(input())
ls = []
la = ls.append
for i in range(1, n + 1):
    s = input().split()
    la((i, s[0], int(s[1])))
if debug:
    print("ls:",ls)
ls = sorted(ls, key=lambda x: x[2], reverse=1)
ls = sorted(ls, key=lambda x: x[1])
if debug:
    print("ls(sorted):",ls)
if debug:
    print("debug end")
for x in ls:
    print(x[0])

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

int main(){
    int n , m ;
    cin >> n >> m ;
    int W[n] , V[n] ;
    rep(i,n) cin >> W[i] >> V[i] ;
    ll A[n][m+1] ;
    fill(A[0],A[n],0) ;
    rep(i,n){
        rep(j,m+1){
        int nj = min( W[i] + j , m ) ;
        A[i][nj] = V[i] ;
        }
    }
    for(int i = 1 ; i < n ;i++ ){
        rep(j,m+1){
            if( j + W[i] <= m ) A[i][ j + W[i] ] = max( A[i-1][j] + V[i] , A[i][ j + W[i] ] ) ;
            A[i][j]  = max( A[i-1][j] , A[i][j] ) ;
        }
    }
    cout << A[n-1][m] << endl;
}

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

def dfs(cur, a, b, c):
  if cur == N:
    if min(a,b,c) > 0:
    	return abs(a-A) + abs(B-b) + abs(C-c) - 30
    else:
      return 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