akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> cnt;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ++ cnt[a];
    }

    for(int i=0; i<m; ++i){
        int b, c;
        cin >> b >> c;
        while(b > 0){
            if(c < cnt.begin()->first)
                break;

            int x = min(b, cnt.begin()->second);
            b -= x;
            cnt.begin()->second -= x;
            cnt[c] += x;

            if(cnt.begin()->second == 0)
                cnt.erase(cnt.begin());
        }
    }

    long long ans = 0;
    for(const auto& p : cnt)
        ans += p.first * (long long)p.second;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = "";
			while ((str = Console.ReadLine()) != null)
			{
				var xy = str.Split(' ').Select(d => double.Parse(d)).ToArray();
				double x1 = xy[0], y1 = xy[1], x2 = xy[2], y2 = xy[3], x3 = xy[4], y3 = xy[5], xp = xy[6], yp = xy[7];

				double x = Math.Sqrt(Math.Pow(x1 - xp, 2) + Math.Pow(y1 - yp, 2));
				double y = Math.Sqrt(Math.Pow(x2 - xp, 2) + Math.Pow(y2 - yp, 2));
				double z = Math.Sqrt(Math.Pow(x3 - xp, 2) + Math.Pow(y3 - yp, 2));

				double a = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
				double b = Math.Sqrt(Math.Pow(x3 - x1, 2) + Math.Pow(y3 - y1, 2));
				double c = Math.Sqrt(Math.Pow(x2 - x3, 2) + Math.Pow(y2 - y3, 2));

				double S1 = area(a, x, y);
				double S2 = area(b, x, z);
				double S3 = area(c, y, z);
				double S = area(a, b, c);

				Console.WriteLine(((S > S1 + S2) && (S > S2 + S3) && (S > S1 + S3)) ? "YES" : "NO");
			}
		}

		static double area(double a, double b, double c)
		{
			double t = (a + b + c) / 2;
			return Math.Sqrt(t * (t - a) * (t - b) * (t - c));
		}
	}
}

Measured memory_bytes: 6096
// https://atcoder.jp/contests/abc153/tasks/abc153_b
#include <bits/stdc++.h>
#define in cin >> 
#define out cout <<
#define Vi vector<int>
#define FOR(i,k,l) for(int i(k); i<l;i++)
#define M 100002

using namespace std;

int main(void) {
    int H, N;
    Vi vec(M);
    cin >> H >> N;
    
    FOR(i,0,N) {
        in(vec[i]);
    }

    int total = 0;
    
    FOR(i,0,N) {
        total += vec[i];
    }

    if (total >= H) out("Yes");
    else out("No");
}

Measured memory_bytes: 640
N, M = map(int, input().split())

graph = [[False for j in range(N)] for i in range(N)]

am = [0] * M
bm = [0] * M


def judge(visited):
    for v in visited:
        if not v:
            return True
    else:
        # 完走 橋ではない
        return False


def dfs(visited, n):
    visited[n] = True

    for k, v in enumerate(visited):
        if v:
            continue

        if not graph[n][k]:
            continue

        visited = dfs(visited, k)

    return visited


def main():
    for i in range(M):
        # 0-indexed
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1

        am[i] = ai
        bm[i] = bi

        graph[ai][bi] = True
        graph[bi][ai] = True

    ans = 0

    for ai, bi in zip(am, bm):
        graph[ai][bi] = False
        graph[bi][ai] = False

        # 訪問済 All False
        visited = dfs([False] * N, 0)

        if judge(visited):
            ans += 1

        # 元に戻す
        graph[ai][bi] = True
        graph[bi][ai] = True

    print(ans)
    return


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C, D;

int main(void){
	
	scanf("%d %d %d %d", &A, &B, &C, &D);
	
	int ans = 0;
	if(A <= C) ans = min(B, D) - C;
	else ans = min(B, D) - A;
	
	if(ans < 0) printf("0\n");
	else printf("%d\n", ans);
	
    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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 (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

const int INF = 1e18;

int score(int a, int t) {
  if (t == 0 || t == 4) return a;
  if (t == 1 || t == 3) {
    if (a == 0) return 2;
    return a % 2;
  }
  return (a + 1) % 2;
}

int A[222222];
int dp[222222][5];

signed main() {
  int n;
  cin >> n;
  rep (i, n) cin >> A[i];
  rep (i, n+1) rep (j, 5) dp[i][j] = INF;
  rep (j, 5) dp[0][j] = 0;

  rep (i, n) {
    rep (j, 5) {
      if (j > 0) dp[i][j] = min(dp[i][j], dp[i][j-1]);
      dp[i+1][j] = min(dp[i+1][j], dp[i][j] + score(A[i], j));
    }
  }

  int ret = INF;
  rep (i, 5) {
    ret = min(ret, dp[n][i]);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 10496
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();
      
        int count = 0;
        char[] c = S.toCharArray();
        for(char c1 : c) {
            count++;
            if (count!= K){
            System.out.print(c1);
            }else{
            String tmp = String.valueOf(c1);
            System.out.print(tmp.toLowerCase());
            
            }
          
        }
        
        
    System.out.println();
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
//#define MAXN 
using namespace std;
int n,a,b;

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if((a-b)%2==0) printf("Alice\n");
	else printf("Borys\n");
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
	string data;
	int b = 0, e = 0;
	int len;
	cin >> data;
	len = data.length();
	for(int i = 0; i < len; i++){
		if(data[i] == 'A'){
			b = i;
			break;
		}
	}
	for(int i = len - 1; i >= 0; i--){
		if(data[i] == 'Z'){
			e = i;
			break;
		}
	}
	//cout << "e:" << e << " b:" << b << endl;
	cout << e - b + 1<< endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    cout<<(N-1)/2<<endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 K;
  cin >> K;
  vector<int64> v({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});
  K--;
  cout << v[K] << endl;
}


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

int n, ta = 1;

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i / ta == 2) {
			ta = i;
		}
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff(x,a,b) for(int x=a;x<=b;++x)
#define fff(x,a,b) for(int x=a;x>=b;--x)
using namespace std;
typedef long long ll;
void rd(int &v){char ch;for(ch='*';ch<'0'||ch>'9';ch=getchar());for(v=0;ch>='0'&&ch<='9';ch=getchar()) v=v*10+ch-'0';}
int n,d;
int main()
{
	cin>>n>>d;
	d=d+d+1;
	int ans=0;
	if(n%d) ans++;
	ans+=n/d;
	cout<<ans;
}

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

int main() {
 string c;
 cin>>c; 
 if(c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
   cout<<"vowel"<<endl;
   
 }else{
   cout<<"consonant"<<endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, t;
    cin >> n >> t;
    int ans = INF;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        if(y <= t) chmin(ans, x);
    }
    if(ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math 
if __name__=="__main__":
    while True:
        x=float(raw_input())
        h=float(raw_input())
        if x==0 and h==0 :
            break
        tra=math.sqrt((x/2)**2+h**2)
        ans=x**2+tra*x*2
        print "%5f"%(ans)
     #   print ans

Measured memory_bytes: 6440
import math
a = list(map(int,input().split()))
xy = [map(int, input().split()) for _ in range(a[0])]
x, y = [list(i) for i in zip(*xy)]
b = 0
for i in range(a[0]):
  c = math.sqrt(x[i]**2 + y[i]**2)
  if c <= a[1]:
    b += 1

print(b)

Measured memory_bytes: 116752
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }


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

	int N, K;
	cin >> N >> K;
	map<int, int> mp;
	int ans = 1;
	int M = K;
	if(N == 1){
		cout << K << endl;
		return 0;
	}
	for(int i=2;i*i<=K;i++){
		while(M % i == 0){
			mp[i]++;
			if(mp[i] >= N){
				ans *= i;
				mp[i] = 0;
			}
			M /= i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
  "use strict"
  const temp = input.split("\n");

	const n = parseInt(temp.shift());
  const an = temp.shift().split(" ");
  
  let sumOfReciprocal = 0;
  for(let i = 0; i < n; i++){
    sumOfReciprocal += 1 / parseInt(an[i]);
  }
  console.log(1 / sumOfReciprocal)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 18888
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]=' ';
}
int n,a,b;
void write(int a,int b,int lim){
	if(a==b)return print(a),void();
	int x=(a^b)&(-(a^b));
	lim^=x;
	int y=lim&-lim;
	write(a,a^y,lim),write(a^y^x,b,lim);
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d%d",&n,&a,&b);
	if(__builtin_popcount(a^b)&1^1)return puts("NO"),0;
	puts("YES");
	write(a,b,(1<<n)-1);
	return Ot(),0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)
 
signed main(){
  string S,T,ans="No";
  cin>>S>>T;
  rep(i,S.size()){
    S=S.back()+S.substr(0,S.size()-1);
    if(S==T){
      ans="Yes";
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
while True:
    string = input().split()
    a = int(string[0])
    op = string[1]
    b = int(string[2])
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break



Measured memory_bytes: 5592
x1, y1, x2, y2 = map(int, input().split())
x = x2-x1
y = y2-y1
s = "R"*x + "U"*y + "L"*x + "D"*(y+1) + "R"*(x+1) + "U"*(y+1) + "LU" + "L"*(x+1) + "D"*(y+1) + "R"
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

const int MAX_V = 10005;

class Edge{
	public:
		int to, cap, rev;
		Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

class Flow{
	private:
		bool used[MAX_V];
		int level[MAX_V]; //s??????????????¢
		int iter[MAX_V]; //???????????§??????????????£??????
		int dfs(int v, int t, int f){
			if(v == t) return f;
			used[v] = true;
			rep(i,G[v].size()){
				Edge &e = G[v][i];
				if(not used[e.to] && e.cap > 0){
					int d = dfs(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		int dfs_(int v, int t, int f){
			if(v == t) return f;
			for(int &i = iter[v]; i < G[v].size(); i++){
				Edge &e = G[v][i];
				if(e.cap > 0 && level[v] < level[e.to]){
					int d = dfs_(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		void bfs(int s){
			memset(level, -1, sizeof(level));
			queue<int> que;
			level[s] = 0;
			que.push(s);
			while(not que.empty()){
				int v = que.front(); que.pop();
				rep(i,G[v].size()){
					Edge &e = G[v][i];
					if(e.cap > 0 && level[e.to] < 0){
						level[e.to] = level[v] + 1;
						que.push(e.to);
					}
				}
			}
		}
	public:
		vector<Edge> G[MAX_V];
		void addEdge(int from, int to, int cap){
			G[from].push_back(Edge(to, cap, static_cast<int>(G[to].size())));
			G[to].push_back(Edge(from, 0, static_cast<int>(G[from].size() - 1)));
		}
		int fordFulkerson(int s, int t){
			int flow = 0;
			while(true){
				memset(used, 0, sizeof(used));
				int f = dfs(s, t, INF);
				if(f == 0) return flow;
				flow += f;
			}
		}
		int dinic(int s, int t){
			int flow = 0;
			while(true){
				bfs(s);
				if(level[t] < 0) return flow;
				memset(iter, 0, sizeof(iter));
				int f;
				while( (f = dfs_(s, t, INF)) > 0){
					flow += f;
				}
			}
		}
};

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

	int g[305][305] = {{0}};
	Flow flow;
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = i + 1;
		flow.addEdge(a,b,1);
		flow.addEdge(b,a,1);
	}

	int s, t;
	cin >> s >> t;
	s--; t--;
	cout << flow.fordFulkerson(s,t) << endl;

	set<int> v;
	rep(i,n){
		for(auto j : flow.G[i]){
			if(j.cap == 0 && g[i][j.to] == 0){
				v.emplace(g[j.to][i]);
			}
		}
	}

	cout << v.size() << endl;
	for(auto i : v){
		cout << i  << endl;
	}
}

Measured memory_bytes: 3808
#B - Can you solve this?
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = list(range(N))
for i in range(N):
    A[i] = list(map(int, input().split()))
    gokaku = 0
for i in range(N):
    gokei = 0
    for j in range(M):
        gokei += A[i][j]*B[j]
    gokei += C
    if gokei > 0:
        gokaku += 1
print(int(gokaku))

Measured memory_bytes: 38384
#include <stdio.h>

int main(){
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if(A != B && A != C){
    printf("%d\n", A);
  }
  if(B != A && B != C){
    printf("%d\n", B);
  }
  if(C != A && C != B){
    printf("%d\n", C);
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int i, j;
	char s[11];
	int len;
	long long sum;

	scanf("%s%n", s, &len);

	sum = 0;
	for (i = 0; i < 1 << len - 1; i++) {
		long long cur = 0;
		for (j = 0; j < len; j++) {
			cur = cur * 10 + s[j] - '0';
			if (~i >> j & 1) {
				sum += cur;
				cur = 0;
			}
		}
	}

	printf("%lld\n", sum);

	return 0;
}


Measured memory_bytes: 128
import sys


def main():
    n, a, b = map(int, input().split())

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = n
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if a >= mod:
        ans += mod
    else:
        ans += a
    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
    int n;
    cin>>n;
    
    long long int ans=0;
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    
    cout<<ans;
}

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

int main()
{	
	int n,m;
	cin >> n >> m;
	int build[100][100] = {{}};

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> build[i][j];
		}
	}
	int multi[100] ={};
	for(int i=0;i<m;i++){
		cin >> multi[i];
	}


	for(int i=0;i<n;i++){
		int pr=0;
		for(int j=0;j<m;j++){
			pr += multi[j]*build[i][j];
		}
		cout << pr << endl;
	}

	



    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    ans = [[] for j in range(M)]

    if N % 2:
        for i in range(M):
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
    else:
        memo = 0
        for i in range(M):
            memo = i
            if (i + 1) * 4 >= N:
                break
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
            memo += 1

        for j in range(memo, M):
            ans[j].append(j + 1)
            ans[j].append(N - j - 2)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23836
# -*- coding: utf-8 -*-

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

abcd = digit_list(input())

for i in range(8):
    num = abcd[0]
    formula = str(abcd[0])
    if i % 2:
        num += abcd[1]
        formula += "+"
        formula += str(abcd[1])
    else:
        num -= abcd[1]
        formula += "-"
        formula += str(abcd[1])
    if (i >> 1) % 2:
        num += abcd[2]
        formula += "+"
        formula += str(abcd[2])
    else:
        num -= abcd[2]
        formula += "-"
        formula += str(abcd[2])
    if (i >> 2) % 2:
        num += abcd[3]
        formula += "+"
        formula += str(abcd[3])
    else:
        num -= abcd[3]
        formula += "-"
        formula += str(abcd[3])
    if num == 7:
        formula += "=7"
        print(formula)
        break


Measured memory_bytes: 3064
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){
  string S, T;
  cin >> S;
  cin >> T;

  int N = 3;
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == T[i]){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pi 3.1415
	 
int main()
{
	fastio;
	float r;
	cin>>r;
	float ans=((2)*pi)*r;
	printf("%f\n",ans);
	
	return 0;
	
	
}

Measured memory_bytes: 3808
// abc126d(https://atcoder.jp/contests/abc126/tasks/abc126_d)
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;

int N;
long long K;
vector<int> A;
const long long INF = 1LL << 60;

int main() {
    cin >> N >> K;
    A.assign(N, 0);
    rep(i, 0, N) {
        int t;
        cin >> t;
        t--;
        A[i] = t;
    }
    vector<int> kyori(N, 0);
    int next = 0;
    int tmp = 0;
    while(true) {
        next = A[tmp];
        if(next == 0 || kyori[next] != 0) {
            break;
        } else {
            kyori[next] = kyori[tmp] + 1;
            tmp = next;
            if(kyori[next] == K) {
                cout << next + 1 << endl;
                return 0;
            }
        }
    }
    // rep(i, 0, N) { cout << kyori[i] << endl; }
    int hen = kyori[tmp] - kyori[next] + 1;
    // cout << hen << endl;
    // cout << kyori[next] << endl;
    K = K - kyori[next];

    K = K % hen;
    // cout << K << endl;
    rep(i, 0, N) {
        if(kyori[i] == kyori[next] + K) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4840
n, x = input().split()
l = input().split()
l.insert(0,0)
a = 0
flag = 0
for i in range(int(n)+1):
    a = a + int(l[i])

    if a > int(x):
        print(i)
        flag = 1
        break

if flag == 0:
    print(int(n)+1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(){
  int n,a,i,j,f,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    f=0;

    if(a==2 || a==3){
      cnt++;
      continue;
    }
    for(j=2;j<=sqrt(a);j++){
      if(a%j==0){
	f=1;
	break;
      }
    }
    if(f!=1)cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;
//あとでやる https://atcoder.jp/contests/abc114/tasks/abc114_d
int main(){
    int N;
    cin>>N;
    cout<<(1110-N)<<endl;
}

Measured memory_bytes: 3528
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string.h>
#include <sstream>
using namespace std;

template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int main(){
  int n;
  string str;
  
  while(cin >> n, n){
    cin >> str;
    int list[10];
    while(n--){
      memset(list, 0, sizeof(list));
      
      string tmp="";
      for(int i = 0 ; i < str.size() ; i++){
	list[str[i]-'0']++;
	if(i == str.size()-1 || str[i] != str[i+1]){
	  string t = toString(list[str[i]-'0']);
	  tmp += t + str[i];
	  memset(list, 0, sizeof(list));
	}

      }
      str = tmp;
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout<<s<<endl;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
const int mn=1e5+10;
int n,k,a[mn];
int b;
bool ans;
int main() {
	scanf("%d %d",&n,&k);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+(n+1));
	b=-1;
	for (int i=1;i<n;i++) {
		int c=a[i+1]-a[i];
		if (c==0)
			continue;
		if (b==-1)
			b=c;
		else b=min(b,c);
	}
	ans=false;
	if (b==-1) {
		if (a[1]==k)
			ans=true;
	}
	else {
		for (int i=1;i<=n;i++)
			if (a[i]>=k&&(a[i]-k)%b==0) {
				ans=true;
				break;
			}
	}
	if (!ans)
		printf("IM");
	printf("POSSIBLE\n");
	return 0;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
c = [[int(i) for i in input().split()] for i in range(a)]
#print(c)
hantei=False
d=[]
for i in range(a):
    if b>=c[i][1]:
        d.append(c[i])
        hantei=True
    else:
        continue
if hantei==False:
    print("TLE")
else:
    print(sorted(d)[0][0])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
#define whi 0
#define gra 1
#define bla 2
using namespace std;
int n,d[101],color[101];
bool g[101][101];
queue<int> num;
void dft(){
	int a,i,j;
	for(i=1;i<=n;i++){
	color[i]=whi;
		d[i]=-1;
	}
	num.push(1);
	d[1]=0;
	color[1]=gra;
	while(!num.empty()){
		a=num.front();
		num.pop();
		for(int v=1;v<=n;v++){
			if(g[a][v] && color[v]==whi){
				num.push(v);
				color[v]=gra;
				d[v]=d[a]+1;
			}
			color[a]=bla;
		}
	}	
}
main(){
	int u,k,v,i,j;
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)
		g[i][v]=false;
	}
	for(i=1;i<=n;i++){
	cin>>u>>k;
		for(j=1;j<=k;j++){
		cin>>v;
			g[u][v]=true;
		}
	}
	dft();
	for(i=1;i<=n;i++)
	cout<<i<<" "<<d[i]<<endl;
	return 0;
}



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

int main() {
  int X;
  int N;
  cin >> X >> N;
  if (N == 0) {
    cout << X << endl;
    return 0;
  }
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  int up = X;
  int down = X;
  int j = 0;
  while (1) {
    int flag = 0;
    int count = 0;
    up = X + j;
    down = X - j;
    for (int x : p) {
      if (x == down) {
        count++;
      }
    }
    if (count == 0) {
      cout << down << endl;
      flag = 1;
    }
    count = 0;
    for (int x : p) {
      if (x == up) {
        count++;
      }
    }
    if (flag == 1) {
      break;
    }
    if (count == 0) {
      cout << up << endl;
      flag = 1;
    }
    if (flag == 1) {
      break;
    }
    j++;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n ;
int arr[500005] ;
string str ;

void solve()
{
    cin >> n ;
    int ans = 0 ;
    for(int i=1 ; i<n ; i++)
    {
        ans += (n-1)/i ;
    }
    cout << ans ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 3652
import java.util.Scanner;
import java.util.*;

public class Main {

 public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);
  Integer testCase = sc.nextInt();
  List<String> vA = new ArrayList < String > ();
  for (int i = 0; i < testCase; i++)
   vA.add(sc.next());

  Integer ac = 0;
  Integer wa = 0;
  Integer tle = 0;
  Integer re = 0;


  for (String v: vA) {

   switch (v) {
    case "AC":
     ac++;
     break;
    case "WA":
     wa++;
     break;
    case "TLE":
     tle++;
     break;
    case "RE":
     re++;
     break;
   }
  
  }
   
   System.out.println(String.format("AC x %s \nWA x %s \nTLE x %s \nRE x %s ",ac,wa,tle,re));
 }

}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());
    auto start = clock();
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<int> dp(n + 1, -1);
    dp[n] = 0;
    int st = n - 1, en = n;
    while(st >= 0) {
        if (s[st] == '1') {
            --st;
            continue;
        }
        while(en - st > m) --en;
        while(dp[en] < 0 && en > st) --en;
        if (en == st) {
            cout << -1;
            return 0;
        } else {
            dp[st] = dp[en] + 1;
        }
        --st;
    }
//    for (int i = 0; i <= n; ++i) {
//        cout << dp[i] << ' ';
//    }
//    cout << endl;
    st = 0, en = 1;
    while (st != n) {
        while(dp[en] != dp[st] - 1) ++en;
        cout << en - st << ' ';
        st = en;
        ++en;
    }

    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

Measured memory_bytes: 1104
def main():
    S = input()

    i = 0
    while i < len(S):
        if S[i:i+7] == "dreamer" and (i+7 == len(S) or (i+7 < len(S) and S[i+7] != "a")):
            i += 7
        elif S[i:i+6] == "eraser":
            i += 6
        elif S[i:i+5] == "dream" or S[i:i+5] == "erase":
            i += 5
        else:
            return "NO"

    return "YES"



if __name__ == '__main__':

    print(main())


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  ll r, g, b, n;
  cin >> r >> g >> b >> n;
  ll cnt = 0;
  for (int i = 0; i <= n / r; i++){
    for (int j = 0; j <= n / g; j++){
      ll x = i * r;
      ll y = j * g;
      ll z = n - (x + y);
      if (z >= 0 && z % b == 0){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
A_m = list(map(int, input().split()))

left_toll, right_toll = 0, 0
for a_i in A_m:
    if a_i < X:
        left_toll += 1
    else:
        right_toll += 1

print(left_toll if left_toll < right_toll else right_toll)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n), b(1, 0);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        b.push_back(b.back() + a[i]);
    }

    ll m = LLONG_MAX;
    for (ll i = 1; i < n; i++)
    {
        if (abs((b.back() - b[i]) - b[i]) < m)
        {
            m = abs((b.back() - b[i]) - b[i]);
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    if(n%2==0||m%2==0)
    {
        if(n==1||m==1)printf("1\n");
        else printf("%lld\n",n*m/2);
    }
    else
    {
        if(n==1||m==1)printf("1\n");
        else printf("%lld\n",(m+1)/2*(n+1)/2+(m/2)*(n/2));
    }
}


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


#define	ll_int	long long int


typedef struct data_t{
	ll_int data;
	struct data_t *next;
}DATA_T;

DATA_T *BOX;
DATA_T **LAST_IN;


// 配列の初期化
void Init(int n)
{
	int i;

	for(i = 0; i < n; i++)
		LAST_IN[i] = &BOX[i];
}


// 指定した添え字の箱の末尾へデータを追加
void Push_back(int t, ll_int x)
{
	DATA_T *p;

	if( (p = (DATA_T *)malloc(sizeof(DATA_T))) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	p->data = x;
	p->next = NULL;
	LAST_IN[t]->next = p;
	LAST_IN[t] = p;
}


// 内容の表示
void Dump(int t)
{
	DATA_T *p;

	if(LAST_IN[t] == &BOX[t]){
		printf("\n");
		return;
	}

	for(p = BOX[t].next; p != NULL; p = p->next){
		printf("%lld", p->data);
		if(p->next != NULL)
			printf(" ");
	}
	printf("\n");
}


// 指定した配列の内容をクリア
void Clear(int t)
{
	LAST_IN[t] = &BOX[t];
}


// LsをLtの末尾に接合する
void Splice(int s, int t)
{
	LAST_IN[t]->next = BOX[s].next;
	LAST_IN[t] = LAST_IN[s];
	Clear(s);
}

int main()
{
	int n, q;
	int query, s, t;
	ll_int x;
	int i;

	scanf("%d %d", &n, &q);

	BOX = (DATA_T *)malloc(sizeof(DATA_T) * n);
	LAST_IN = (DATA_T **)malloc(sizeof(DATA_T *) * n);

	Init(n);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query == 0){
			scanf("%d %lld", &t, &x);
			Push_back(t, x);
		}else if(query == 1){
			scanf("%d", &t);
			Dump(t);
		}else if(query == 2){
			scanf("%d %d", &s, &t);
			Splice(s, t);
		}
	}

	return 0;
}

/*
	topic1のVector2を改良して、
	新たな機能を持たせただけ
*/


Measured memory_bytes: 17392
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int beki(int N) {
	while (N > 1) {
		if (N % 2 != 0)return 0;
		N /= 2;
	}
	return 1;
}
int keta(int N) {
	int res = 0;
	while (N > 0) {
		res++;
		N /= 2;
	}
	return res;
}

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

	int N;
	cin >> N;
	if (beki(N)) {
		puts("No");
		return 0;
	}

	vector<pair<int, int>>e;
	vector<int>in(2*N+1);
	for (int i = 1; i <= (N - 1) / 2; i++) {
		e.pb({ 1,2*i });
		e.pb({ 2 * i,2 * i + 1 });
		e.pb({ 1,2 * i + 1 + N});
		e.pb({ N + 2 * i + 1, N + 2 * i });
		in[1]++;
		in[2*i]++;
		in[2*i]++;
		in[2*i+1]++;
		in[2*i+1+N]++;
		in[N+2*i+1]++;
		in[N+2*i]++;
	}
	if (N % 2 == 0) {
		int k = keta(N);
		int x = (1 << (k-1));
		int y = N - x + 1;
		if (in[x] == 1)x += N;
		if (in[y] == 1)y += N;
		e.pb({N,x});
		e.pb({2*N,y});
	}
	e.pb({ N+1,3 });
	
	puts("Yes");
	fore(x, e)cout << x.first << " " << x.second << endl;
	
	return 0;
}

Measured memory_bytes: 4848
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("6 4 3");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8 3 9");
            //4
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("12 3 7");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[0];
        int B = wkArr[1];
        int C = wkArr[2];

        int Answer = C - (A - B);
        Console.WriteLine(Math.Max(0, Answer));
    }
}


Measured memory_bytes: 13396
NN = 100001

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

number = [0 for _ in range(NN)]
summ = 0
for a in A:
  number[a] += 1
  summ += a 
Q = int(input())

#mapping = [0 for _ in range(NN)]
for i in range(Q):
  B, C = map(int,input().split())
  summ += number[B]*(C-B)
  number[C] += number[B]
  number[B] = 0
  """
  summ += 
  if uf.parents[B] < 0:
    summ += -uf.parents[B] * (C-B)
    uf.union(C, B) 
  """
  print(summ)


Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M;
ll dp[111111];

int main()
{
    cin >> N >> M;
    vector<int> a(M + 1);
    for (int i = 0; i < M; i++)
    {
        cin >> a[i];
    }
    M = 0;
    dp[0] = 1;
    if (a[0] == 1)
        M++;
    else
        dp[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        if (a[M] == i)
            M++;
        else
            dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= mod;
    }
    cout << dp[N] << endl;
}

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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll gcd(ll x, ll y) {
    if (x % y == 0LL) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin>>v[i];
  ll t = v[0];
  for(ll i = 1; i < N; i++) t=gcd(t,v[i]);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  if(K<=v[0]&&(K-v[0])%t==0) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1024
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
    return res;
}
const int N=1e6+5;
int fac[N],ifac[N],n,k,res;
inline int C(R int n,R int m){return m<0||m>n?0:1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
inline int calc(R int n,R int m,R int k){return dec(C(n+m,n),C(n+m,n+1-k));}
void init(int n=1e6){
    fac[0]=ifac[0]=1;fp(i,1,n)fac[i]=mul(fac[i-1],i);
    ifac[n]=ksm(fac[n],P-2);fd(i,n-1,1)ifac[i]=mul(ifac[i+1],i+1);
}
int main(){
//  freopen("testdata.in","r",stdin);
    scanf("%d%d",&n,&k);
    if(k<n)return puts("0"),0;
    init();
    for(R int a=max((k+1)>>1,n),b;a<=k;++a){
        b=k-a;
        R int t=min(a-(n-1),b);
        if(a-(n-1)==t)--t;
        upd(res,calc(a,b-(a==b),-t));
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 8572
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b,c;
	int s=0;
	cin>>a>>b>>c;
	for(int i=min(a,b);i>=1;i--){
		if(a%i==0 && b%i==0)s++;
		if(s==c){
			cout<<i<<endl;
			return 0;
		}
	}
}
		


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice {
	int s[6];
	void roll(char c) {
		int b;
		if (c == 'E') {
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'W') {
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'N') {
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
		if (c == 'S') {
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;
		}
		if (c == 'R') {
			b = s[1];
			s[1] = s[2];
			s[2] = s[4];
			s[4] = s[3];
			s[3] = b;
		}
	}
	int top() {
		return s[0];
	}
	int right() {
		return s[2];
	}
	int left() {
		return s[3];
	}
	int front() {
		return s[1];
	}
};

bool same(Dice a, Dice b) {
	for (int i = 0; i < 6; i++) if (a.s[i] != b.s[i])return false;
	return true;
}
int main() {
	Dice d[2];
	for (int j = 0; j < 2; j++) {
		for (int i = 0; i < 6; i++) { cin >> d[j].s[i]; }
	}
	bool f = false;
	
	for (int i = 0; i < 4; i++) {
		d[1].roll('R');
		for (int j = 0; j < 4; j++) {
			d[1].roll('N');
			if (same(d[0], d[1])) f = true;
		}


	}
	d[1].roll('E');
	for (int j = 0; j < 4; j++) {
		d[1].roll('N');
		if (same(d[0], d[1])) f = true;
	}
	d[1].roll('W');
	d[1].roll('W');
	for (int j = 0; j < 4; j++) {
		d[1].roll('N');
		if (same(d[0], d[1])) f = true;
	}

	cout << (f ? "Yes" : "No")<<endl;
	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

vi F(vi a, vi b) {
    vi c = a;
    c.insert(end(c), ALL(b));
    sort(RALL(c));
    vi ret = {c[0], c[1]};
    return ret;
}
vector<vi> calc(vector<vi> f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if (j & i) f[j] = F(f[j], f[j ^ i]);
        }
    }
    return f;
}
signed main() {
    int N;
    cin >> N;
    vi A(1 << N);
    cin >> A;
    
    vector<vi> f(1 << N);
    REP(i, 1 << N) f[i] = {A[i], 0};
    vector<vi> g = calc(f);
    
    int ans = 0;
    REPF(i, 1, 1 << N) {
        chmax(ans, g[i][0] + g[i][1]);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 33792