akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct SCC{
    int V;
    vector<vector<int>> G, rG;
    vector<int> vs; // 帰りがけ順の並び
    vector<int> cmp; //属する強連結成分トポロジカル順序
    vector<bool> used;

    SCC(){}
    SCC(int n){
        V = n;
        G = vector<vector<int>>(n);
        rG = vector<vector<int>>(n);
    }

    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }

    void dfs(int v){
        used[v] = true;
        rep(i,G[v].size())if(!used[G[v][i]]) dfs(G[v][i]);
        vs.push_back(v);
    }

    void rdfs(int v, int k){
        used[v]=true;
        cmp[v]=k;
        rep(i,rG[v].size())if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }

    int scc(){
        used = vector<bool>(V,false);
        vs.clear();
        rep(i,V)if(!used[i]) dfs(i);

        used = vector<bool>(V,false);
        cmp = vector<int>(V);
        int num_scc = 0;
        for(int i=vs.size()-1; i>=0; --i)if(!used[vs[i]]) rdfs(vs[i],num_scc++);
        return num_scc;
    }
};

struct TwoSat{
    int v;
    SCC graph;

    // v literals
    // 0~v-1: true
    // v~2v-1: false

    TwoSat(int num_literal){
        v = num_literal;
        graph = SCC(2*v);
    }

    inline int num(int id, bool b){return id+(b?0:v);}

    void add_clause(int x, bool X, int y, bool Y){
        graph.add_edge(num(x,!X), num(y,Y));
        graph.add_edge(num(y,!Y), num(x,X));
    }

    // 割り当てが可能か調べる
    bool calc(){
        graph.scc();
        rep(i,v)if(graph.cmp[i]==graph.cmp[v+i]) return false;
        return true;
    }

    // リテラルの真偽値を返す
    vector<bool> get_literals(){
        assert(calc());
        vector<bool> res(v);
        rep(i,v) res[i] = (graph.cmp[i]>graph.cmp[v+i]);
        return res;
    }
};

// (floor, left/right)
using pi = pair<int,int>;

pi READ(){
    int num;
    string lr;
    cin >>num >>lr;

    return {num, (lr=="right")};
}

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

    vector<pair<pi,pi>> v(m);
    rep(i,m){
        char sep;
        pi x,y;

        x = READ();
        cin >>sep;
        y = READ();

        v[i] = {x,y};
    }

    auto valid = [&](int c){
        const int N = 10010;
        TwoSat t(N);
        rep(i,m){
            pi x = v[i].fi, y = v[i].se;
            if(x.fi<c && y.fi<c){
                t.add_clause(x.fi, !x.se, y.fi, !y.se);
            }
        }

        return t.calc();
    };

    int l=1, r=n+1;
    while(r-l>1){
        int mid = (l+r)/2;
        if(valid(mid)) l=mid;
        else r=mid;
    }
    cout << l << endl;
    return 0;
}



Measured memory_bytes: 5340
#include <stdio.h>

char s[101];//文字列//

int main(void) {
	int i;
	int n;//文字数//
	int x = 0;
	int max = 0;

	scanf("%d", &n);
	
	for (i = 0; i <= n; i++) {
		scanf("%c", &s[i]);
	}

	   	  
	for (i = 1; i <= n; i++) {
		if (s[i] == 'I') {
			x = x + 1;
		}
		else {
			x = x - 1;
		}

		if (x > max) {
			max = x;
		}
	}

	printf("%d", max);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MMOD=2019;

ll pow_MMOD(ll a,ll b){
  if(b==0){
    return 1;
  }
  else if(b%2==0){
    ll t=pow_MMOD(a,b/2);
    return t*t%MMOD;
  }
  else{
    return pow_MMOD(a,b-1)*a%MMOD;
  }
}

int main() {
  string s;
  cin >> s;
  ll k=s.size();
  vl a(k);
  rep(i,k){
    a[i]=((s[i]-'0')*pow_MMOD(10,k-1-i))%MMOD;
  }
  vl sum(k+1);
  sum[0]=0;
  FOR(i,1,k+1){
    sum[i]=(sum[i-1]+a[k-i])%MMOD;
  }
  ll ans=0;
  sort(sum.begin(),sum.end());
  ll n=0;
  rep(i,k){
    if(sum[i]==sum[i+1]){
      n++;
    }
    else{
      ans+=n*(n+1)/2;
      n=0;
    }
  }
  ans+=n*(n+1)/2;
  cout << ans << endl;
}

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

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

  long long sum = 0;
  for (long long i = 1; i <= n; i++)
  {
    if ((i % 3) != 0 && (i % 5) != 0)
    {
      sum += i;
    }
    }

  cout << sum << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = INT64_MAX;
    for(int i = 0; i < n - k + 1; i++) {
        int j = i + k - 1;
        if(a[i] >= 0) {
            ans = min(ans, a[j]);
        }else if(a[i] < 0 && a[j] <= 0) {
            ans = min(ans, -a[i]);
        }else {
            ans = min(ans, min(-2 * a[i] + a[j], -a[i] + 2 * a[j])); 
        }
    }
    cout << ans << "\n";
}

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

using namespace std;
const double PI=3.14159265358979323846;

int main(void){
    double r;
    cin >> r;
    
    double ans = 2 * r * PI;
    cout << fixed << setprecision(15);
    cout << ans << endl;
    
}

Measured memory_bytes: 3784
n = int(input())
builds = [[[0]*10 for _ in range(3)] for _ in range(4)]
for _ in range(n):
    b, f, r, v = map(int, input().split())
    builds[b-1][f-1][r-1] += v

for i, b in enumerate(builds):
    for _b in b:
        print(" ", end="")
        print(*_b)

    if i < 3:
        print("#"*20)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int n,m;
int a[505][505];
int cnt;
struct p{
	int x1,y1,x2,y2;
}nd[250005];
int tp;
int main(){
	int i,j;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	n=read(),m=read();
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++) a[i][j]=read();
	for(i=1;i<=n;i++)
		for(j=1;j<m;j++)
			if(a[i][j]%2)
				nd[++tp]=(p){i,j,i,j+1},a[i][j]--,a[i][j+1]++;
	for(i=1;i<n;i++)
		if(a[i][m]%2)
			nd[++tp]=(p){i,j,i+1,j},a[i][j]--,a[i+1][j]++;
	printf("%d\n",tp);
	for(i=1;i<=tp;i++) 
	printf("%d %d %d %d\n",nd[i].x1,nd[i].y1,nd[i].x2,nd[i].y2);
	return 0;
}

Measured memory_bytes: 6668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define rrep(n,i) for(int i = n-1; i>=0; --i)
#define PI 3.14159265
#define INF 1e9
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
	int n,w; cin >>n >> w;
	vector<int> h(n),we(n); 
	rep(i,n){
		cin >> h[i] >> we[i];
	}	

	vector<vector<ll>> dp(n+1,vector<ll> (w+1));

	for(int i = 0; i<n ; i++){
		for(int j = 0; j<=w ;j++){
			if(j>=h[i]){
				dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
				dp[i+1][j] = max(dp[i+1][j],dp[i][j-h[i]] + we[i]);
			}else{
				dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			}
		}
	}



	cout << dp[n][w] << endl;
	

	return 0;
}

Measured memory_bytes: 80256
function Main(input) {
  // 入力
  input = input.split(" ");
	//input = input.split("\n");
	//tmp = input[1].split(" ");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
  var c = parseInt(input[2], 10);
  var ans = "";

  // 計算
  if (a === 5 && b === 5 && c === 7) {
    ans = "YES";
  } else if (a === 5 && b === 7 && c === 5) {
    ans = "YES";
  } else if (a === 7 && b === 5 && c === 5) {
    ans = "YES";
  } else {
    ans = "NO";
  }
  
	//出力
	console.log('%s', ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

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

    sort(d, d+N);
    int cnt = d[N/2] - d[N/2-1];
    cout << cnt << endl;    

    return 0;
}

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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll N;

void dfs(string target, char ch_max) {
    if (target.size() == N) {
        cout << target << endl;
        return;
    }

    for (char c = 'a'; c <= ch_max + 1; c++) {
        string s = target;
        s += c;
        dfs(s, max(ch_max, c));
    }
}
int main() {
    cin >> N;
    dfs("", 'a' - 1);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  bool ans = false;
  for(int i =0; i<10; i++){
    for(int j = 0; j <10; j++){
      if(i*j == N){
        ans = true;
      }
    }
  }
  if(ans){
    cout << "Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

int main() {
    vector<int> v(5, 0);
    for(int i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        v[a]++;
        v[b]++;
    }
    int cnt = 0;
    for(auto it : v) {
        if(it >= 3) {
            cout << "NO";
            return 0;
        }
        if(it == 2) {
            cnt++;
        }
    }
    if(cnt >= 3) {
        cout << "NO";
    }
    else {
        cout << "YES";
    }

}

Measured memory_bytes: 256
// AtCoder Beginners Contest 177
// A - Don't be late

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;

int main()
{
	long long D, T, S;
    cin >> D >> T >> S;
	if (D > S*T) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>

void print(vector<int> arr){for(auto i:arr){printf("%d ",i);}cout<<endl;}

int main()
{
    char ch;cin>>ch;
    cout<<++ch;
    return 0;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  char X = A.at(0) - 0x20, Y = B.at(0) - 0x20, Z = C.at(0) - 0x20;

  cout << X << Y << Z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;

int main(){
	cin >> n;
	REP(i, n){
		int a, b;
		cin >> a >> b;
		if (a%b == 0)cout << b << endl;
		else cout << a%b << endl;
	}
}

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

using namespace std;

int main() {
  long long a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;

  long long x = min({a * 4, b * 2, c});
  long long y = d;

  if (x * 2 > y) {
    cout << (n / 2) * y + (n % 2) * x << endl;
  } else {
    cout << n * x << endl;
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,m,x;
  cin >> n >> m >> x;
  set<int> s;
  rep(i,m){
    int k;
    cin >> k;
    s.insert(k);
  }
  int f = 0;
  int l = 0;
  rep(i,n){
    if(!s.count(i)) continue;
    if(i < x) f++;
    else l++;
  }
  int ans = min(f,l);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, m, sum = 0, tmp;

    cin >> n >> m;
    //    vector<int> a(n);
    rep(i, m)
    {
        cin >> tmp;
        sum += tmp;
    }
    cout << ((n - sum) < 0 ? -1 : n - sum) << endl;
}

Measured memory_bytes: 3632
N = int(input())

dp = [0 for _ in range(N+1)]
for x in range(1,int(N**0.5)+1):
    for y in range(1,int(N**0.5)+1):
        for z in range(1,int(N**0.5)+1):
            t = x * x + y * y + z * z + x * y + y * z + z * x
            if t <= N:
                dp[t] += 1

for i in range(1,N+1):
    print(dp[i])

Measured memory_bytes: 9568
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    char name[11]; 
    long count[5] = {0};
    long ans = 0;
    for (int i = 0; i < n; i++){
        scanf("%s", name);
        switch(name[0]){
            case 'M':
            count[0] += 1;
            break;
            case 'A':
            count[1] += 1;
            break;
            case 'R':
            count[2] += 1;
            break;
            case 'C':
            count[3] += 1;
            break;
            case 'H':
            count[4] += 1;
            break;
            default:
            break;
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 4; j++){
            for(int k = j+1; k < 5; k++){
                ans += (count[i] * count[j] * count[k]);
            }
        }
    }
    printf("%ld\n", ans);
    return 0; 
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int[] a = nextIntArray(sc, 3);
		int K = sc.nextInt();

		sc.close();

		Arrays.sort(a);

		a[2] = a[2] * (1 << K);

		long ans = a[0] + a[1] + a[2];
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <bitset>
const int PRIME_SIZE = 1000000;
int psize;
bitset<PRIME_SIZE + 1> bprime;
int prime[PRIME_SIZE / 10 + 1000];
int Eratosthenes(int n) {
  psize = 0;
  bprime.set();
  bprime[0] = bprime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (!bprime[i]) { continue; }
    prime[psize++] = i;
    if ((long long)i * i > n) { continue; }
    for (int j = i * i; j <= n; j += i) {
      bprime[j] = false;
    }
  }
  return psize;
}

int n;
int main() {
  Eratosthenes(10000);
  while (scanf("%d", &n) > 0) {
    int ans = 0;
    FOREQ(i, 1, n) {
      ans += bprime[i] && bprime[n - i + 1];
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

const long long MOD = 1000000007;

void solve(int H, int W, vs &a){
    vvi dp(1005, vi(1005, 0));
    dp[0][0] = 1;
    rep(h, H) rep(w, W) {
        if (h+1 <= H-1 && a[h+1][w] == '.') {
            dp[h+1][w] += dp[h][w];
            dp[h+1][w] %= MOD;
        }
        if (w+1 <= W-1 && a[h][w+1] == '.') {
            dp[h][w+1] += dp[h][w];
            dp[h][w+1] %= MOD;
        }
    }
    cout << dp[H-1][W-1] << endl;
}

int main(){
    int H;
    scanf("%d",&H);
    int W;
    scanf("%d",&W);
    vs a(H);
    for(int i = 0 ; i < H ; i++){
        cin >> a[i];
    }
    solve(H, W, a);
    return 0;
}


Measured memory_bytes: 5248
a,b,c,d = input().split()

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

if abs(a - c) <= d:
    print('Yes')
elif abs(a - b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')


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

using namespace std;

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

int main()
{
    FAST();
    int n;
    cin >> n;
    n%=1000;
    if(n > 0)n=1000-n;
    cout << n;
    return 0;
}


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

using namespace std;

typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

// 場合の数を格納
// i桁目を剰余類がj(0-12)になったときの場合の数(各桁において'?'の場合は0-9で走査して調べる)
int dp[100005][15];

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

int main(){
    string S;
    cin >> S;
    int n = S.length();
    
    int mul = 1;
    vector<int> m(n);       // (10のべき乗)%13
    for(int i = n-1; i >= 0; --i){
        m[i] = mul;
        mul = (mul * 10) % 13;
    }
    
    // dpテーブルの初期化
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= 12; ++j){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 1;
    
    for(int i = 0; i < n; ++i){
        if(S[i] != '?'){        // 数が確定しているとき
            int temp = S[i] - '0';  // 今見ている桁の数字
            for(int j = 0; j <= 12; ++j){
                if(dp[i][j] == INF)     continue;       // ありえないときはcontinue
                
                dp[i + 1][(j + m[i] * temp) % 13] = dp[i][j];          // 剰余が(j + m[i]*temp) % 13になる
            }
        }
        else{               // 数が確定していないとき
            for(int N = 0; N <= 9; ++N){        // 0-9を代入して剰余を計算
                for(int j = 0; j <= 12; ++j){
                    if(dp[i][j] == INF)     continue;
                    
                    int id = (j + m[i] * N) % 13;       // 更新するindex
                    if(dp[i + 1][id] == INF){
                        dp[i + 1][id] = dp[i][j];
                    }
                    else{
                        dp[i + 1][id] = (dp[i + 1][id] + dp[i][j]) % mod;
                    }
                }
            }
        }
    }
    
    // for(int i = 0; i <= n; ++i){
    //     for(int j = 0; j <= 12; ++j){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    if(dp[n][5] == INF)     dp[n][5] = 0;

    cout << dp[n][5] << endl;
}

Measured memory_bytes: 6784
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<i32> = read_as_vec();
    let (n, m) = (line[0], line[1]);
    let mut counter: Vec<i32>  = vec![0;m as usize];

    for i in 0..n{
        let line: Vec<usize> = read_as_vec().into_iter().skip(1).collect::<Vec<_>>();
        for item in &line{
            counter[*item-1] += 1;
        }

    }
    //println!("{:?}", counter);
    println!("{}", counter.into_iter().filter(|x| *x == n).collect::<Vec<_>>().len())
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    ll n = 0, x = 0, ans = 0;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n - 1)
    {
        if (a.at(i) + a.at(i + 1) > x)
        {
            ans += max((ll)0, abs(x - (a.at(i) + a.at(i + 1)))); //キャンディの数を0より小さくしないようにしてる
            a.at(i + 1) = max((ll)0, a.at(i + 1) - abs(x - (a.at(i) + a.at(i + 1))));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

int main(){
	int a[4],b[4],c,d,i,j;
	while(std::cin>>a[0]){
	for(i=1;i<4;i++){
	std::cin>>a[i];
	}for(i=0;i<4;i++){
	std::cin>>b[i];
	}
	c=0;
	d=0;
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			if(i==j&&a[i]==b[j]){
			c++;
			}if(i!=j&&a[i]==b[j]){
			d++;
			}
		}
	}
	std::cout<<c<<" "<<d<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int k;

        if (n % 2 == 0) {
            k = n / 2;
        } else {
            k = (n/2) + 1;
        }

        System.out.println(k);




    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

int mod(int a){
	return a%1000000007;
}
int input(const char& a)
{
	if(a=='#')
		return -1;
	return 0;
}

int main()
{
	const int num=1001;
	int grid[num][num]={};
	int h,w;
	cin>>h>>w;
	int dp[num][num]={};
	dp[1][1]=1;
	char a;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>a;
			grid[i][j]=input(a);
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(grid[i][j]==-1){
				dp[i][j]=0;
				continue;
			}
			if(i==1&&j==1)
				continue;
			dp[i][j]=mod(dp[i-1][j]+dp[i][j-1]);
		}
	}
	cout<<dp[h][w]<<endl;
}
	

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
    if (x) cout<<"YES";
    else cout<<"NO";
}
ll gcd (ll a, ll b)
{
    if (b == 0) return a;
    return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
    ll t = a;
    a = b;
    b = t;
}
bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
// ----- code here ----- //
void solve()
{
    ll a;
    cin>>a;
    ll x = a + a*a + (a*a)*a;
    cout<<x;
}
// ----- code here ----- //

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    // for checking the execution time
    #endif
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
        cout<<endl;
    }
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec";
    #endif
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const long long  mod = 1000000007;
int main() {
	long long N; cin >> N;
	long long counter[N + 1]={};
	for (int i =1; i <=N; i++) {
		long long p = i;
		for (int j = 2; j <= N; j++) {
			while (p%j == 0) { p /= j; counter[j]++; }
		}
	}
	long long ans = 1;
	for (int i = 1; i < N + 1; i++) {
		ans *= (counter[i] + 1);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x,y = map(int, input().split())

a = (4*x-y)/2
b = (y-2*x)/2
if (4*x-y)%2 == 0 and (y-2*x)%2 == 0 and a >=0 and b>=0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
	std::vector<int> a;
    int n;
  	std::cin>>n;
	a.assign(n, 0);
  	for  ( int i = 0 ; i < n ; ++i ) {
	   std::cin>>a[i] ;	 
    }
  	std::sort(a.begin(), a.end());
  	auto iter = std::unique(a.begin(), a.end());
  	if ( iter == a.end() ) std::cout<<"YES"<<std::endl;
  	else std::cout<<"NO"<<std::endl;
  	return 0;
}



Measured memory_bytes: 1024
N = int(input())
p = list(map(int, input().split()))
p.insert(0, -1)

j = [0] * (N + 1)
for i in range(1, N + 1):
    if p[i] == i and j[i - 1] == 0:
        j[i] = 1
print(sum(j))

Measured memory_bytes: 14004
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut vv = vec![0f64; n];
    for i in 0..n - 1 {
        vv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    vv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    vv.sort_by(|a, b| a.partial_cmp(b).unwrap());

    let mut ans = vv[0];
    for i in 1..n {
        ans = (ans + vv[i]) / 2f64;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <unordered_map>

char find_upperchar(std::unordered_map<char,int> &um,char x){
    char ret='@';
    for(char c=x+1;c<='z';++c){
        if(um[c]==0){
            ret=c;
            break;
        }
    }
    return ret;
}

int main(){
    std::string s;
    std::cin>>s;
    std::unordered_map<char,int> um;
    std::string ans="";
    for(auto c:s)um[c]++;
    if(s.size()==26){
        for (int i = s.size()-1; i >= 0; --i) {
            char t=find_upperchar(um,s[i]);
            um[s[i]]=0;
            if(isalpha(t)){
                ans=s.substr(0,i);
                ans.push_back(t);
                break;
            }
        }
    }
    else{
        for(char c='a';c<='z';++c){
            if(um[c]==0){
                ans=s;
                ans.push_back(c);
                break;
            }
        }
    }
    if(ans.size()==0)ans="-1";
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;

  vector <int> a(n+1);
  vector <int> b(n); 
  vector <int> c(n-1);

  for ( int i = 0; i < n; i++ ){
    cin >> a.at(i);
  }
  a.at(n) = 0;
  for ( int i = 0; i < n; i++ ){
    cin >> b.at(i);
  }
  for ( int i = 0; i < (n-1); i++ ){
    cin >> c.at(i);
  }

  int point = 0;
  int tmp = 0;

  for ( int i = 0; i < n; i++) {
    tmp = a.at(i);
    if ( (a.at(i+1) - a.at(i)) == 1 ) {
      point = point + c.at(tmp-1);
    }
    point = point + b.at(tmp-1);
 
  }

  cout << point << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <set>
using namespace std;

#define MP make_pair

bool flag[53][53][4];

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

int main(){
	int n,x0,y0,t;
	cin >> n >> x0 >> y0 >> t;
	x0++;
	y0++;
	for(int k=0;k<n;k++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a++;b++;c++;d++;
		if(a==c){
			if(b>d)swap(b,d);
			for(int i=b;i<d;i++){
				flag[a][i][0] = 1;
			}
			for(int i=d;i>b;i--){
				flag[a][i][2] = 1;
			}
		}
		if(b==d){
			if(a>c)swap(a,c);
			for(int i=a;i<c;i++){
				flag[i][b][1] = 1;
			}
			for(int i=c;i>a;i--){
				flag[i][b][3] = 1;
			}
		}
	}
	map<int,int> mp;
	int s = 0;
	for(int i=0;i<t;i++){
		int a;
		cin >> a;
		char b;
		cin >> b;
		s += a;
		if(b=='N'){
			mp[s] = 0;
		}else if(b=='E'){
			mp[s] = 1;
		}else if(b=='S'){
			mp[s] = 2;
		}else{
			mp[s] = 3;
		}
	}
	queue<pair<pair<int,int>,pair<int,int> > >q;
	map<pair<pair<int,int>,pair<int,int> >,bool> m;
	if(flag[x0][y0][0]==1){
		q.push(MP(MP(x0,y0),MP(0,0)));
	}
	if(flag[x0][y0][1]==1){
		q.push(MP(MP(x0,y0),MP(0,1)));
	}
	if(flag[x0][y0][2]==1){
		q.push(MP(MP(x0,y0),MP(0,2)));
	}
	if(flag[x0][y0][3]==1){
		q.push(MP(MP(x0,y0),MP(0,3)));
	}
	set<pair<int,int> > ans;
	while(1){
		auto x = q.front();
		q.pop();
		int a,b,c,d;
		a = x.first.first;
		b = x.first.second;
		c = x.second.first;
		d = x.second.second;
		//cout << a <<" " << b << " " <<c << " " << d << endl;
		if(c>s)break;
		if(c==s){
			ans.insert(MP(a-1,b-1));
		}
		if(mp.find(c+1)!=mp.end()){
			if(d==mp[c+1]){
				for(int i=0;i<4;i++){
					if(i!=d&&(i+4-d)%2==0)continue;
					if(flag[a+dx[d]][b+dy[d]][i]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]==0){
						m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]=1;
						q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,i)));
					}
				}
			}else{
				if((d+4-mp[c+1])%2!=0&&flag[a+dx[d]][b+dy[d]][mp[c+1]]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1]))]==0){
					m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1]))]=1;
					q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1])));
				}
			}
		}else{
			for(int i=0;i<4;i++){
				if(i!=d&&(i+4-d)%2==0)continue;
				if(flag[a+dx[d]][b+dy[d]][i]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]==0){
					m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]=1;
					q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,i)));
				}
			}
		}
	}
	for(auto x:ans){
		cout << x.first << " " << x.second << endl;
	}
	return 0;
}


Measured memory_bytes: 52832
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B;
    char op;
    cin>>A>>op>>B;
    if(op=='+') cout<<A+B<<endl;
    else cout<<A-B<<endl;
}

Measured memory_bytes: 256
/*
 *    author:  gantheory
 *    created: 2018-06-03 22:38:29
 */
#include <bits/stdc++.h>

using namespace std;

// Mod Integer {{{
const int MOD = 998244353;
template <int _MOD>
class ModInt {
 public:
  static const auto MOD = _MOD;
  template <class T>
  using integral_only = typename enable_if<is_integral<T>::value>::type;

  int x;
  constexpr ModInt() : x() {}
  template <class T, integral_only<T>* = nullptr>
  ModInt(T _x) {
    x = _x % MOD;
    if (x < 0) x += MOD;
  }
  ModInt operator-() const { return {x == 0 ? 0 : MOD - x}; }
  ModInt& operator+=(ModInt rhs) {
    x += rhs.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }
  ModInt& operator-=(ModInt rhs) {
    x -= rhs.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(ModInt rhs) {
    x = (long long)x * rhs.x % MOD;
    return *this;
  }
  ModInt& operator/=(ModInt rhs) { return *this *= rhs.inv(); }
  ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
  ModInt inv() const {
    // should work for non-prime MOD if gcd(x, MOD) = 1
    int a = x, b = MOD, u = 1, v = 0;
    while (b != 0) {
      int t = a / b;
      a -= t * b, u -= t * v;
      swap(a, b), swap(u, v);
    }
    return u;
  }
  template <class T, integral_only<T>* = nullptr>
  ModInt pow(T e) {
    ModInt r = 1, p = *this;
    while (e) {
      if (e & 1) r *= p;
      p *= p, e >>= 1;
    }
    return r;
  }
  bool operator==(ModInt rhs) const { return x == rhs.x; }
  bool operator!=(ModInt rhs) const { return x != rhs.x; }
  bool operator<(ModInt rhs) const { return x < rhs.x; }
  bool operator<=(ModInt rhs) const { return x <= rhs.x; }
  bool operator>(ModInt rhs) const { return x > rhs.x; }
  bool operator>=(ModInt rhs) const { return x >= rhs.x; }
  friend string to_string(ModInt i) { return to_string(i.x); }
  friend ostream& operator<<(ostream& os, ModInt o) { return os << o.x; }
  friend istream& operator>>(istream& is, ModInt& i) {
    is >> i.x;
    i.x %= MOD;
    if (i.x < 0) i.x += MOD;
    return is;
  }
};
using mint = ModInt<MOD>;
// }}}

const int N = 3e5 + 10;

long long n, a, b, k;
mint f[N];

mint C(int x, int y) { return f[x] / f[y] / f[x - y]; }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  cin >> n >> a >> b >> k;

  f[0] = 1;
  for (int i = 1; i <= n; ++i) f[i] = f[i - 1] * i;

  mint ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (a * i > k) continue;
    long long res = k - a * i;
    if (res % b) continue;
    res /= b;
    if (res > n) continue;
    ans += C(n, i) * C(n, res);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1408
N = list(input())

flg = 0
for i in range(1,len(N)):
    if N[i]=="9":
        continue
    else:
        flg = 1
        break

if flg:
    print((len(N)-1)*9+int(N[0])-1)
else:
    print((len(N)-1)*9+int(N[0]))

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

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
        //primeFactors.Dump();
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i <= n)
        {
            if(n % i == 0){
                n /= i;
                yield return i;
            }else{
                i++;
            }
             
            if(i > Math.Sqrt(tmp)){
                i = int.MaxValue; //???????????????
                yield return n;
            }
        }
    }
}

Measured memory_bytes: 12112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,count,m,n;
    vector <int> v;
    string s1,s2;
    cin>>s1>>s2;
    m = s1.size();
    n = s2.size();
    d = m-n +1;
    for(int i=0;i<d;i++)
    {
        count=0;
        for(int j=i,k=0;j<m;j++,k++)
        {
            if(s1[j]!=s2[k] && k<n)
                count++;
        }
        v.push_back(count);

    }
    cout<<*min_element(v.begin(),v.end());
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n, h;
    cin >> n >> h;
    vector<int> v;
    v.push_back(0);
    ll max_a = 0;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        max_a = max(max_a, a);
        v.push_back(b);
    }
    sort(v.begin(), v.end(), greater<ll>());
    vector<ll> u;
    u.push_back(v[0]);
    for (int i = 1; i < n; i++) {
        if (v[i] < max_a) {
            u.push_back(max_a + u[i - 1]);
        }
        else
            u.push_back(v[i] + u[i - 1]);
    }

    auto check = [&](int x) {
        if (x > u.size()) {
            if (h <= u.back())
                return true;
            else {
                return (h - u.back() + max_a - 1) / max_a <= x - u.size();
            }
        }
        else return u[x - 1] >= h;
    };

    ll ok = h;
    ll ng = 0;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }
    cout << ok<< "\n";
}

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

int N, M, A[1 << 18], B[1 << 18], deg[1 << 18], col[1 << 18], col2[1 << 18], cnts, cntv;
vector<int>X[1 << 17], Z[1 << 17], G;

void dfs(int pos) {
	if (col[pos] >= 1) return;
	col[pos] = cnts; G.push_back(pos);
	for (int i = 0; i < X[pos].size(); i++) {
		dfs(X[pos][i]);
	}
}

void dfs2(int pos) {
	if (col2[pos] >= 1) return;
	col2[pos] = cntv;
	for (int i = 0; i < Z[pos].size(); i++) dfs2(Z[pos][i]);
}

pair<int, int> solve(vector<int>I) {
	if (I.size() == 0) return make_pair(0, 0);

	vector<int>T;
	for (int i = 0; i < I.size(); i++) {
		if (deg[I[i]] >= 6) return make_pair(1, 3);
		if (deg[I[i]] == 4) T.push_back(I[i]);
	}

	if (T.size() == 0) return make_pair(1, 1);
	if (T.size() == 1) return make_pair(1, 2);
	if (T.size() >= 6) return make_pair(1, 3);

	for (int i = 0; i < T.size(); i++) {
		for (int j = i + 1; j < T.size(); j++) {
			for (int k : I) { Z[k].clear(); col2[k] = 0; }

			cntv = 0;

			for (int pos1 : I) {
				for (int pos2 : X[pos1]) {
					if (pos1 == T[i] || pos1 == T[j] || pos2 == T[i] || pos2 == T[j]) continue;
					Z[pos1].push_back(pos2);
				}
			}
			for (int k : X[T[i]]) {
				if (col2[k] >= 1 || k == T[i] || k == T[j]) continue;
				cntv++; dfs2(k);
			}

			if (cntv < X[T[i]].size() || cntv < X[T[j]].size()) return make_pair(1, 3);
		}
	}
	return make_pair(1, 2);
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]); deg[A[i]]++;
		X[B[i]].push_back(A[i]); deg[B[i]]++;
	}

	for (int i = 1; i <= N; i++) {
		if (deg[i] % 2 == 0) continue;
		cout << "No" << endl;
		return 0;
	}

	int L = 0, R = 0;
	for (int i = 1; i <= N; i++) {
		if (col[i] >= 1) continue;
		G.clear(); cnts++;
		dfs(i);
		pair<int, int> Z = solve(G);
		L += Z.first; R += Z.second;
	}
	if (L <= 3 && 3 <= R) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 19960
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    string t;
    cin >> t;
    for(int i = 0; i < t.size(); i++) {
        if(t[i] == '?') {
            /*
            if(i+1 < t.size() && t[i+1] == 'D') t[i] = 'P';
            else if(i-1 >= 0 && t[i-1] == 'P') t[i] = 'D';
            else t[i] = 'D';
            */
           t[i] = 'D';
        }
    }
    /*
    for(int i = 0; i < t.size(); i++) {
        if()
    }
    */
    int ans = 0;
    for(int i = 0; i < t.size(); i++) {
        if(t[i] == 'D') ans++;
    }
    for(int i = 0; i < t.size()-1; i++) {
        if(t[i] == 'P' && t[i+1] == 'D') ans++;
    }
    cout << t << endl;
    //cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N, K, S, T;
   cin >> N >> K >> S >> T;
   if ((S & T) != S) {
      cout << 0;
      return 0;
   }
   vector<int> A(N);
   for (int i = 0; i < N; ++i) cin >> A[i];
   vector<vector<ll>> C(N + 1, vector<ll>(N + 1));
   vector<ll> ways(N + 1);
   for (int i = 0; i <= N; ++i) {
      C[i][0] = 1;
      for (int j = 1; j <= i; ++j) {
         C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
         if (j <= K) ways[i] += C[i][j];
      }
   }
   ll ans = 0;
   for (int mask = 0; mask < (1 << 18); ++mask) {
      if ((mask & (S ^ T)) != mask) continue;
      map<int, int> cnts;
      for (int i = 0; i < N; ++i) {
         if ((A[i] & S) != S) continue;
         if ((A[i] | T) != T) continue;
         ++cnts[A[i] & mask];
      }
      int cf = __builtin_popcount(mask) & 1 ? -1 : 1;
      for (auto z : cnts) ans += cf * ways[z.second];
   }
   cout << ans << "\n";
}


Measured memory_bytes: 3684
#include <stdio.h>
#define N 10000
#define Q 500

int linersearch(int,int *,int);

int main(){

  int i,n,q,key,S[N],T[Q],cnt=0;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&S[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++) scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    if(linersearch(n,S,T[i])==1)cnt++;
  }

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

  return 0;
}

int linersearch(int n,int A[],int key){
  int i=0;

  A[n]=key;
  while(A[i]!=key){
    i++;
    if(i == n)return 0;
  }

  return 1;
}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

//実行部
void Main()
{
  str a, b, c; cin >> a >> b >> c;
  char flag = 'a';
  reverse(all(a)), reverse(all(b)), reverse(all(c));
  while(1)
  {
    if(flag == 'a')
    {
      if(a.size() == 0) fin('A');
      flag = a[a.size() - 1];
      a.pop_back();
    }
    else if(flag == 'b')
    {
      if(b.size() == 0) fin('B');
      flag = b[b.size() - 1];
      b.pop_back();
    }
    else
    {
      if(c.size() == 0) fin('C');
      flag = c[c.size() - 1];
      c.pop_back();
    }
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n, m;
	cin >> n >> m;
	long long int ans = 0;
	ans += min(n, m / 2);
	m = max((long long int)0, m - 2 * n);
	ans += m / 4;
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;


int main() {
  vector<int> x(5);
  rep (i, 5) {
    cin >> x.at(i);
  }

  rep (i, 5) {
    if (x.at(i) == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }

}



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

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

struct Node { int cost,x,y,left,right,oxigen; Node(int a,int b,int c,int d,int e,int f):cost(a),x(b),y(c),left(d),right(e),oxigen(f){} };
bool operator<(const Node& a,const Node& b){ return a.cost>b.cost; }
const int MAXN=16,MAXO=64;
const int INF=1<<28;
int T[MAXN][MAXN];
int W,H,F,M,O;

bool visited[MAXN][MAXN][MAXN][MAXN][MAXO];
inline int ox(int x,int y,int o){ return min( o+(T[y][x]>0?T[y][x]:0)-1, M ); }
inline int cs(int x,int y,int c){ return c+(T[y][x]<0?-T[y][x]:0); }

int dk()
{
        if(O<2) return INF;
        rep(x,MAXN) rep(y,MAXN) rep(l,MAXN) rep(r,MAXN) rep(o,MAXO) visited[x][y][l][r][o]=false;

        priority_queue<Node> Q;
        rep(i,W) Q.push(Node( cs(i,0,0), i, 0, i, i, ox(i,0,O) ));

        while(!Q.empty())
        {
                const Node node = Q.top(); Q.pop();
                if(node.y==H-1){ return node.cost; }
                if(visited[node.x][node.y][node.left][node.right][node.oxigen]) continue;
                visited[node.x][node.y][node.left][node.right][node.oxigen]=true;

                if(node.oxigen==1) continue;
                const int dx[] = { 1, -1 };
                rep(i,2)
                {
                        const int x = node.x+dx[i], y = node.y;
                        if(x<0||x>=W) continue;

                        const int left = min(x,node.left), right = max(x,node.right);
                        const int cost   = ((node.left==left&&node.right==right)?node.cost:cs(x,y,node.cost));
                        const int oxigen = ((node.left==left&&node.right==right)?node.oxigen-1:ox(x,y,node.oxigen));
                        if(oxigen<=0) continue;
                        if(visited[x][y][left][right][oxigen]) continue;
                        Q.push(Node(cost,x,y,left,right,oxigen));
                }

                {
                        const int x = node.x, y = node.y+1;
                        const int cost   = cs(x,y,node.cost);
                        const int oxigen = ox(x,y,node.oxigen);
                        if(oxigen<=0) continue;
                        if(visited[x][y][x][x][oxigen]) continue;
                        Q.push(Node(cost,x,y,x,x,oxigen));
                }
        }

        return INF;
}

int main()
{
        while(cin>>W>>H&&(W|H))
        {
                cin>>F>>M>>O;
                rep(y,H) rep(x,W) cin>>T[y][x];

                int res = dk();
                if(res>F){ cout<<"NA"<<endl; } else { cout<<res<<endl; }
        }

        return 0;
}

Measured memory_bytes: 5428
M, D = map(int, input().split())
ans = 0
keta_1 = 0
keta_10 = 0
for i in range(M+1):
    for k in range(D+1):
        keta_1 = k % 10
        keta_10 = k // 10
        if keta_1 > 1 and keta_10 > 1 and keta_1 * keta_10 == i:
            ans += 1
print(ans)


Measured memory_bytes: 3316
s = input()
if s[0] != "A":
    print("WA")
    exit()
if not s[1].islower():
    print("WA")
    exit()
if not s[-1].islower():
    print("WA")
    exit()
s = list(s)
judge = s[2:-1]
if "C" not in judge:
    print("WA")
    exit()
else:
    judge.remove("C")

if "".join(judge).islower() or "".join(judge) == "":
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064