akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int a=sc.nextInt();
    	int b=sc.nextInt();

    	if(a%3==0) {
    		System.out.println("Possible");
    	}else if(b%3==0) {
    		System.out.println("Possible");
    	}else if((a+b)%3==0) {
    		System.out.println("Possible");
    	}else {
    		System.out.println("Impossible");
    	}

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

pair< pair<int, int>, vector<int> > read();
vector<string> think(pair< pair<int, int>, vector<int> > *);
void write(vector<string> *);

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

  auto input = read();
  auto output = think(&input);
  write(&output);

  return 0;
}

pair< pair<int, int>, vector<int> > read() {
  int n, k, q, a;
  auto query = vector<int>();

  scanf("%d %d %d", &n, &k, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &a);
    query.push_back(a);
  }
  return make_pair(make_pair(n, k), query);
}

vector<string> think(pair< pair<int, int>, vector<int> > *input) {
  auto nk = input->first;
  auto a = input->second;

  auto n = nk.first;
  auto k = nk.second;

  auto result = vector<string>();

  auto score = vector<int>(n + 1, 0);
  for (auto who : a) {
    score.at(who)++;
  }

  for (int i = 1; i < score.size(); i++) {
    int othersCorrect = a.size() - score.at(i);
    if (k - othersCorrect > 0) {
      result.push_back("Yes");
    } else {
      result.push_back("No");
    }
  }
  return result;
}

void write(vector<string> *output) {
  for (auto e : *output) {
    cout << e << endl;
  }
}


Measured memory_bytes: 7284
n,d=map(int, input().rstrip().split())
m=[]
for _ in range(n):
    arr=list(map(int, input().rstrip().split()))
    m.append(arr)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a = 0
        for k in range(d):
            a += (m[i][k] - m[j][k])**2
        x = int(a**(1/2))
        if x**2 == a:
            ans+=1
print(ans)


Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const long long Inf = 2e18;
const long long mod = 1e9 + 7;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
long long A[100005];
vector <int> Adj[100005];

void DFS(int node, int p = -1)
{
	long long sum = 0, m = 0;
	for(auto x : Adj[node])
	{
		if(x == p)
			continue;
		DFS(x, node);
		m = max(m, A[x]);
		sum += A[x];
	}
	long long op = 0;
	if(2 * m > sum)
	{
		op = sum - m;
	}
	else
	{
		op = sum / 2;
	}
	if((int)Adj[node].size() == 1)
	{
		return;
	}
	if(A[node] > sum)
	{
		cout << "NO";
		exit(0);
	}
	if(sum - A[node] > op and (int)Adj[node].size() > 1)
	{
		cout << "NO";
		exit(0);
	}
	A[node] = 2 * A[node] - sum;
	if(A[node] < 0)
	{
		cout << "NO";
		exit(0);
	}
}

int main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
	}
	if(n == 2)
	{
		if(A[1] == A[2])
		{
			cout << "YES";
			return 0;
		}
		else
		{
			cout << "NO";
			return 0;	
		}
	}
	for(int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	for(int i = 1; i <= n; i++)
	{
		if((int)Adj[i].size() > 1)
		{
			DFS(i);
			if(A[i] != 0)
			{
				cout << "NO";
				return 0;
			}
			cout << "YES";
			return 0;
		}
	}
}

Measured memory_bytes: 16536
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e3 + 5;
int main() {
    abdelrahman010
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000;
    return 0;
}

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

int main()
{
    string s;
    cin >> s;

    int cnt = 0;
    while (1) {
        char ch = 'B';
        if (s.back() == 'B') ch = 'W';
        for (int i = (int)s.size()-1; i >= 0; i--) {
            if (s[i] == ch) break;
            else s.pop_back();
        }
        if (s.empty()) break;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 2000000000000000000
int a[MAX],b[MAX];
int main()
{
    int n,m,i,j,k;
    scanf("%d %d %d",&n,&m,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<m;i++)
    {
        scanf("%d",&b[i]);
    }
    int rem=k;
    for(j=0;j<m;j++)
    {
        if(b[j]<=rem)
        {
            rem=rem-b[j];
        }
        else
        {
            break;
        }
    }
    int ans=j;
    for(i=0;i<n;i++)
    {
        while(j>0&&rem<a[i])
        {
            rem=rem+b[j-1];
            j--;
        }
        if(rem<a[i]) break;
        rem=rem-a[i];
        ans=max(ans,i+j+1);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


int Main(int H, int W, VS &S)
{
    const int INF = 100000000;
    int ans = 0;
    int HW = H*W;
    VVI d(HW, VI(HW, INF));
    REP(i, HW) {
        REP(j, HW) {
            if(i == j) d[i][j] = 0;
            else if(abs(i-j) == 1 && (i/W == j/W) && S[i/W][i%W] == '.' && S[j/W][j%W] == '.') d[i][j] = 1;
            else if(abs(i-j) == W && S[i/W][i%W] == '.' && S[j/W][j%W] == '.') d[i][j] = 1;
        }
    }
    REP(k, HW) REP(i, HW) REP(j, HW) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    REP(i, HW) REP(j, HW) if(d[i][j] < INF) chmax(ans, d[i][j]);
    return ans;
}

int main(void){
    int H, W;
    cin >> H >> W;
    VS S(H);
    REP(i, H) cin >> S[i];
    cout << Main(H, W, S) << endl;
    return 0;
}

Measured memory_bytes: 896
import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
#import numpy as np

from collections import deque

def main():
	s=input().rstrip()
	ans="Yes"
	n=len(s)
	for i in range(n):
		if s[i]!=s[-i-1]:
			ans="No"
	for i in range(n//2):
		if s[i]!=s[n//2-i-1]:
			ans="No"
	print(ans)





if __name__ == "__main__":
	main()

Measured memory_bytes: 38384
def main():
  X, Y = map(int, input().split())
  if Y%2 != 0:
    return "No"

  x = -X + Y/2
  y = 2 * X - Y/2

  if x < 0 or y < 0:
    return "No"
  else:
    return "Yes"

print(main())

Measured memory_bytes: 9172
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
l = {'r':'p','s':'r','p':'s'}
L = ['' for i in range(n)]
tmp = ['r','s','p']
for i in range(n):
    x = t[i]
    if (i - k) >= 0 and L[i-k] == l[x]:
        tmp.remove(L[i-k])
        if (i + k) <= (n-1) and l[t[i+k]] != l[x]:
            tmp.remove(l[t[i+k]])
        L[i] = tmp[0]
        tmp = ['r','s','p']
    else:
        L[i] = l[x]

score = 0
sc = {'r':r,'s':s,'p':p}
for i in range(n):
    if l[t[i]] == L[i]:
        score += sc[L[i]]

print(score)


Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l),i##R=(r);i<=i##R;i++)
#define DOR(i,r,l) for(int i=(r),i##L=(l);i>=i##L;i--)
#define loop(i,n) for(int i=0,i##R=(n);i<i##R;i++)
#define sf scanf
#define pf printf
#define mms(a,x) memset(a,x,sizeof a)
#define pb push_back
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chkmax(A &x,const B y){if(x<y)x=y;}
template<typename A,typename B>inline void chkmin(A &x,const B y){if(x>y)x=y;}
const int N=1e5+5,P=1e9+7;
int n,q;
struct Graph{
	int tot,to[N<<1],nxt[N<<1],len[N<<1],col[N<<1],head[N];
	void add(int x,int y,int c,int d){tot++;to[tot]=y;nxt[tot]=head[x];col[tot]=c;len[tot]=d;head[x]=tot;}
	void clear(){mms(head,-1);tot=0;}
	#define EOR(G,i,x) for(int i=G.head[x];i!=-1;i=G.nxt[i])
}G;
int fa[N],dep[N],son[N],sz[N],top[N];
int bel[N];
ll dis[N];
struct node{
	int id;
	int x,y,c,d;
}Q[N];
void dfs(int x,int f){
	fa[x]=f;
	dep[x]=dep[f]+1;
	son[x]=0,sz[x]=1;
	EOR(G,i,x){
		int v=G.to[i];
		if(v==f)continue;
		dis[v]=dis[x]+G.len[i];
		bel[v]=G.col[i];
		dfs(v,x);
		sz[x]+=sz[v];
		if(sz[son[x]]<sz[v])son[x]=v;
	}
}
void top_dfs(int x,int f,int tp){
	top[x]=tp;
	if(son[x])top_dfs(son[x],x,tp);
	EOR(G,i,x){
		int v=G.to[i];
		if(v==f||v==son[x])continue;
		top_dfs(v,x,v);
	}
}
int LCA(int a,int b){
	while(top[a]!=top[b]){
		if(dep[top[a]]>dep[top[b]])a=fa[top[a]];
		else b=fa[top[b]];
	}
	return dep[a]>dep[b]?b:a;
}
int cnt[N],cnt1[N];
ll sum[N],sum1[N],ans[N];
vector<int>mark[N];
void redfs(int x,int f){
	loop(i,mark[x].size()){
		int id=mark[x][i];
		if(id>0){
			cnt[id]=cnt1[Q[id].c];
			sum[id]=sum1[Q[id].c];
		}
		else if(id<0){
			id=-id;
//			pf("cnt:%d d:%d sum:%lld\n",cnt1[Q[id].c]-cnt[id],Q[id].d,sum1[Q[id].c]-sum[id]);
			ans[id]+=1ll*(cnt1[Q[id].c]-cnt[id])*Q[id].d-(sum1[Q[id].c]-sum[id]);
		}
	}
	EOR(G,i,x){
		int v=G.to[i];
		if(v==f)continue;
		cnt1[bel[v]]++;
		sum1[bel[v]]+=G.len[i];
		redfs(v,x);
		sum1[bel[v]]-=G.len[i];
		cnt1[bel[v]]--;
	}
}
int main(){
	G.clear();
	sf("%d%d",&n,&q);
	FOR(i,1,n-1){
		int x,y,c,d;
		sf("%d%d%d%d",&x,&y,&c,&d);
		G.add(x,y,c,d),G.add(y,x,c,d);
	}
	dfs(1,0);
	top_dfs(1,0,1);
	FOR(i,1,q){
		sf("%d%d%d%d",&Q[i].c,&Q[i].d,&Q[i].x,&Q[i].y);
		int lca=LCA(Q[i].x,Q[i].y);
		ans[i]=dis[Q[i].x]+dis[Q[i].y]-2*dis[lca];
		mark[lca].pb(i);
		mark[Q[i].x].pb(-i);
		mark[Q[i].y].pb(-i);
	}
	redfs(1,0);
	FOR(i,1,q)pf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 22652
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    char op;
    cin >> a >> op >> b;
    while(op!='?'){
        int c;
        if(op=='+') c=a+b;
        if(op=='-') c=a-b;
        if(op=='*') c=a*b;
        if(op=='/') c=a/b;
        cout << c << endl;
        cin >> a >> op >>b;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
const int INF = numeric_limits<int>::max();
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M;
  in(N); in(M);

  ll xyz[N][3];
  rep(i, N) {
    in(xyz[i][0]);
    in(xyz[i][1]);
    in(xyz[i][2]);
  }
  ll ans = -INF;
  rep(bit, 1 << 3) {
    ll val[N];
    rep(i, N) {
      val[i] = 0;
      rep(j, 3) {
        if ((bit >> j) % 2 == 1)
          val[i] += xyz[i][j];
        else
          val[i] -= xyz[i][j];
      }
    }
    sort(val, val+N, greater<ll>());
    ll sum = 0;
    rep(j, M) {
      sum += val[j];
    }
    chmax(ans, sum);
  }
  out(ans);

  return 0;
}


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

int main(){
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  
  sort(a.begin(), a.end());
  
  cout << a.at(2) - a.at(0) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number_n, i, flag = 0, current = 0;
    number_n = Integer.parseInt(sc.next());
    List<Pair> pair = new ArrayList<Pair>();
    int[] time = new int[number_n];
    int[] goal = new int[number_n];
    for(i = 0; i < number_n; i++) {
      time[i] = Integer.parseInt(sc.next());
      goal[i] = Integer.parseInt(sc.next());
      pair.add(new Pair(time[i], goal[i]));
    }
    pair.sort(Comparator.comparing(Pair::getGoal));
    for(Pair temp : pair) {
      current += temp.time;
      if(temp.goal < current) {
        flag++;
        System.out.println("No");
        break;
      }
    }
    if(flag == 0) System.out.println("Yes");
  }
}

class Pair {
  int time;
  int goal;

  public Pair(int a, int b) {
    this.time = a;
    this.goal = b;
  }

  public int getGoal() {
    return this.goal;
  }
}


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

using namespace std;
typedef long long ll;

const int N=1e5+100;
int a[N];

int main()
{
   int n,k,q;
   scanf("%d%d%d",&n,&k,&q);
   int x;
   ll sum=0;
   for(int i=1;i<=q;i++){
    scanf("%d",&x);
    a[x]++;
   }
  /* for(int i=1;i<=n;i++){
      sum+=a[i];
   }*/
  // cout<<s
   for(int i=1;i<=n;i++){
     if(q-a[i]<k) printf("Yes\n");
     else printf("No\n");
   }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string S;
  cin >> S;
  int sm = 0;
  for (char c : S) sm += c - '0';
  cout << (sm % 9 == 0 ? "Yes" : "No") << nl;
  return 0;
}


Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  rep(i,N){
    cin >> a[i+1];
  }
  set<int> numset;
  numset.insert(1);
  int p = 1;
  int res = 0;
  bool can = false;
  while(1){
    p = a[p];
    res++;
    if(numset.count(p)) break;
    if(p == 2){
      can = true;
      break;
    }
    numset.insert(p);
  }
  if(can){
    cout << res << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char str[100];
	scanf("%s", str);

	int ans[n];
	int x = 0;
	for (int i=0; i<n; i++){
		if (str[i] == 'I'){
			x++;
			ans[i] = x;
		}
		if (str[i] == 'D'){
			x--;
			ans[i] = x;
		}
	}

	int max = 0;
	for (int i=0; i<n; i++){
		if (max < ans[i]){
			max = ans[i];
		}
	}

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

	return 0;
}


Measured memory_bytes: 1712
data = []
n = gets.to_i

while(n != 0)

	data = gets
	data = data.split(nil)
	#配列dataを数値に変換する
	data = data.map{|n| n.to_i}
	data.sort!

	if((data[2]**2) == (data[1]**2) + (data[0]**2))
		puts("YES")
	else
		puts("NO")
	end
	n = n - 1;
end

Measured memory_bytes: 8744
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b,c;cin>>a>>b>>c;
  
  if (a==b and b==c) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import Data.List

main = do
    [h,w] <- map read . words <$> getLine
    as <- map length . group . sort . filter (/= '\n') <$> getContents
    putStrLn $ if solve h w as then "Yes" else "No"

solve h w as
    | odd h && odd w = s4 >= (h-1) * (w-1) `div` 4 && s1 == 1
    | even h && even w = all (== 0) $ map (`mod` 4) as
    | odd h && even w = s4 >= (h-1) * w `div` 4 && s1 == 0
    | even h && odd w = s4 >= h * (w-1) `div` 4 && s1 == 0
    where s4 = sum (map (`div` 4) as)
          s1 = sum (map (`mod` 2) as)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, T;
	cin >> N >> T;
	vector<ll> t(N);
	REP(i, N)cin >> t[i];

	vector<ll> seg[201010];
	ll ind = 0;
	seg[0].push_back(t[0]);
	ll res = 0;
	for(int i=1;i<N;i++){
		if(seg[ind][seg[ind].size()-1] + T >= t[i]){
			seg[ind].push_back(t[i]);
		}else{
			res += (seg[ind][seg[ind].size()-1] + T - seg[ind][0]);
			ind++;
			seg[ind].push_back(t[i]);
		}
	}
	res += (seg[ind][seg[ind].size()-1] + T - seg[ind][0]);
	cout << res << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<vector<pair<int, int> > > nn;
    nn.resize(n);
    for(int i = 0; i < n-1; ++i){
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        nn.at(u-1).push_back(make_pair(v-1, w));
        nn.at(v-1).push_back(make_pair(u-1, w));
    }

    vector<int> color(n, -1);
    stack<int> s;
    color.at(0) = 0;
    s.push(0);
    while(!s.empty()){
        int x = s.top(); s.pop();
        for(pair<int, int> p : nn.at(x)){
            if(color.at(p.first) != -1){ continue; }

            if(p.second % 2){
                color.at(p.first) = 1 - color.at(x);
            }else{
                color.at(p.first) = color.at(x);
            }

            s.push(p.first);
        }
    }

    for(int b : color){ printf("%d\n", b); }
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N;cin>>N;
    
	// 解法
    ll ans = pow(N, 3);
    
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 512
import sys
from collections import deque
input = sys.stdin.readline

n = int(input())
E = [[] for i in range(n)]

for i in range(n-1):
  a, b = map(int, input().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)

c = list(map(int, input().split()))
c.sort()
nums = deque(c)
ans = [0] * n
  
def dfs(cur, pre):
    stack = deque([[cur, pre]])
    while stack:
        cur, pre = stack.pop()
        num = nums.pop()
        ans[cur] = str(num)
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur])

dfs(0, -1)

print(sum(c[:-1]))
print(' '.join(ans))

Measured memory_bytes: 76364
import sys
input=sys.stdin.buffer.readline
n=int(input())
l=list(map(int,input().split()))
f=l[0]
from fractions import gcd

for i in l:
    f=f*i//gcd(f,i)
mod=10**9+7
ans=0
for i in l:
  ans+=f//i
print(ans%mod)


Measured memory_bytes: 5616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

const ll Mod = 1e9 + 7;
const int N = 2e5 + 7;
// dp[i] denotes the maximum beauties of the reamining flowers if we consider all flowers to
// the left of i;
ll Table[N];
 
void update(int i , ll val){
    while(i < N){
        Table[i] = max(Table[i] , val);
        //i *= 2 ;
        i += i&-i;
    }
}
ll query(ll i){
    ll mx = 0;
    while(i){
        mx = max(mx , Table[i]);
        //i /= 2;
        i -= i&-i;
    }
    return mx;
}
 
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n; cin >> n;
    int H[n+1] , A[n+1];
 
    for(int i =1 ;i <= n; i++)
        cin >> H[i];
    for(int i =1 ;i <= n ;i++)
        cin >> A[i];
 
    ll dp[n+1];
    dp[0] = 0;
    ll ans = 0;
    for(int i = 1;i <= n; i++){
        dp[i] = A[i] + query(H[i]);
        update(H[i] , dp[i]);
        ans = max(ans , dp[i]);
    }
 
    cout << ans << endl;
 
 
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size()-1; i++)
    {
        if(s.substr(i, 2) == "AC"){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
s = input()
l =["AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA","AKIHABAR", "AKIHABR", "AKIHBAR", "AKIHBRA", "KIHABAR", "KIHABRA", "KIHBARA","AKIHBR", "KIHABR", "KIHBAR", "KIHBRA", "KIHBR"]
if s in l:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int r[N], f[2020]; 

int main(){
    string s; 
    cin >> s;
    reverse(all(s));
    ll n = s.size(), cur = 0, t = 1; 
    for(int i = 0; i<n; ++i){
        r[i] = (1ll * t * (s[i]-'0'))%2019;
        r[i] %= 2019;
        t = (1ll * t * 10)%2019;
    }
    ll an = 0;
    t = 0;
    for(int i = 0; i<n; ++i){
        t = (t + r[i]) % 2019;
        ++f[t];
    }
    for(int i = 0; i<2019; ++i){
        an += (1ll * f[i] * (f[i]-1))/2;
    }
    an += f[0];
    printf("%lld\n", an);
}

Measured memory_bytes: 4524
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod = 1000000007;
const ll mx =131080;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1


db n;


start;
// op = 0 when n = even
    cin1(n);

    cout << 2*pi*n << "\n";

finish


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    int g = A[0];
    for (int x : A) g = gcd(g, x);
    if (g != 1) {
        cout << "not coprime" << '\n';
        return;
    }

    vector<bool> used(1e6+1, false);
    for (int x : A) {
        vector<int> pri;
        for (int i=2; i*i<=x; ++i) {
            if (x%i == 0) {
                pri.push_back(i);
                while (x%i == 0) x /= i;
            }
        }
        if (x != 1) pri.push_back(x);
        for (int y : pri) {
            if (used[y]) {
                cout << "setwise coprime" << '\n';
                return;
            }
            used[y] = true;
        }
    }
    cout << "pairwise coprime" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 7384
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int H,W; cin >> H >> W;
    char S[H][W]; REP(i,H)REP(j,W) cin >> S[i][j];
    int node[H][W], n=0; REP(i,H)REP(j,W) node[i][j] = n++;

    ll dist[n][n]; REP(i,n)REP(j,n) dist[i][j] = INF;
    REP(i,n) dist[i][i] = 0;

    REP(i,H)REP(j,W){
        if(S[i][j] == '#') continue;
        if(i>0){
            if(S[i-1][j] == '.') dist[node[i][j]][node[i-1][j]] = 1;
        }
        if(i<H-1){
            if(S[i+1][j] == '.') dist[node[i][j]][node[i+1][j]] = 1;
        }
        if(j>0){
            if(S[i][j-1] == '.') dist[node[i][j]][node[i][j-1]] = 1;
        }
        if(j<W-1){
            if(S[i][j+1] == '.') dist[node[i][j]][node[i][j+1]] = 1;
        }
    }

    REP(k,n)REP(i,n)REP(j,n){
        if(i==4 && j ==10){
            int a = 1;
        }
        chmin(dist[i][j], dist[i][k]+dist[k][j]);
    }
    ll ans = 0;
    REP(i,n)REP(j,n) if(dist[i][j] < INF) chmax(ans, dist[i][j]);
    cout << ans << endl;
    return 0;
}

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

int main()
{
  uint64_t n, k;
  cin >> n >> k;
  uint bc[64] {};
  vector<uint64_t> a(n);
  for (auto i = 0; i < n; i++) {
    uint64_t x;
    cin >> x;
    a[i] = x;
    for (auto b = 0; b < 64; b++) {
      if ((x & 1) != 0) {
        bc[b]++;
      }
      x >>= 1;
      if (x == 0) break;
    }
  }
  uint64_t v{0};
  for (auto s = 63; s >= 0; s--) {
    const uint64_t one = 1;
    uint64_t u = one << s;
    if (u > k) continue;
    if (bc[s] <= n / 2) {
      if (v + (one << s) <= k) {
        v += one << s;
      }
    }
  }
  uint64_t ans{0};
  for (auto i = 0; i < n; i++) {
    ans += v ^ a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n;
    int i;
    string s[n];
    map<string, int> ps;
    for(i=0; i<n; i++) {
        cin >> s[i];
        ps[s[i]] += 1;
    }

    cin >> m;
    string t[m];
    for(i=0; i<m; i++) {
        cin >> t[i];
        ps[t[i]] -= 1;
    }

    int max=0;
    for(auto itr=ps.begin(); itr!=ps.end(); ++itr) {
        if(max<=itr->second) {
            max = itr->second;
        }
    }

    cout << max << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct road{
	int to;
	int cost;
};

int main() {
	int n, m;
	char gomi;
	cin >> n >> m;
	vector < vector<road>> vvr(n+1);
	REP(i,m){
		int a, b, c, d;
		cin >> a >> gomi >> b >> gomi >> c >> gomi >> d;
		vvr[a].push_back({ b, c });
		vvr[b].push_back({ a, d });
	}
	int start, goal, money,hashira;
	cin >> start >> gomi >> goal >> gomi >> money >> gomi >> hashira;
	vector<int> cost1(n + 1);
	vector<int> cost2(n + 1);
	vector<bool> cb1(n + 1);
	vector<bool> cb2(n+1);
	REP(i, n + 1){
		cost1[i] = 1 << 30;
		cost2[i] = 1 << 30;
		if (i){
			cb1[i]=false;
			cb2[i] = false;
		}
		else{
			cb1[i] = true;
			cb2[i] = true;
		}
	}
	cost1[start] = 0;
	cost2[goal] = 0;
	while (1){
		int min = 1 << 30;
		int town;
		REP(i,cost1.size()){
			if (!cb1[i])
				if (min > cost1[i]){
					min = cost1[i];
					town = i;
				}
		}

		cb1[town] = true;
		if (town == goal)break;
		REP(i,vvr[town].size()){
			cost1[vvr[town][i].to] = cost1[town] + vvr[town][i].cost;
		}
	}
	while (1){
		int min = 1 << 30;
		int town;
		REP(i, cost2.size()){
			if (!cb2[i])
				if (min > cost2[i]){
					min = cost2[i];
					town = i;
				}
		}
		cb2[town] = true;
		if (town == start)break;
		REP(i, vvr[town].size()){
			if (cost2[vvr[town][i].to] > cost2[town] + vvr[town][i].cost)
			cost2[vvr[town][i].to] = cost2[town] + vvr[town][i].cost;
		}
	}
	cout <<money-hashira-cost1[goal]-cost2[start] << endl;
}

Measured memory_bytes: 1212
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < n; i++) x[i] = scan.nextInt();
        int out = Integer.MAX_VALUE;
        for(int i = 1; i <= 100; i++){
            int sum = 0;
            for(int j = 0; j < n; j++){
                sum += Math.pow(x[j] - i, 2);
            }
            if(out > sum) out = sum;
        }
        System.out.println(out);
        scan.close();
    }
}


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

using namespace std;

int main()
{
  char str[10];
  char str1[]="Sunny",str2[]="Rainy",str3[]="Cloudy";
  cin>>str;
  
  if(strcmp(str,str1)==0)cout<<"Cloudy";
  if(strcmp(str,str2)==0)cout<<"Sunny";
  if(strcmp(str,str3)==0)cout<<"Rainy";
    
  
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      char a;
      int win;
      int lose;
      while(cin >> a){
        if(a == 'o'){
          win++;
        }else{
          lose++;
        }
      }
      int kari = 15 - win - lose;
      if(win+kari > 7){
        cout << "YES" << endl;
      }else{
        cout << "NO" << endl;
      }
    }

Measured memory_bytes: 256
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <cctype>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef stringstream strstm;
#define pb push_back
#define PI acos(-1.0)
#define CLR(a) MST(a,0);
#define E 2.718281829459
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)


int a[4][4];

int main(int argc, char const *argv[])
{	
	_rep(i,1,3)
		_rep(j,1,3) cin >> a[i][j];

	int a1, a2, a3, b1, b2, b3; 
	bool f = 1;
	_for(i,-1000,1000){
		a1 = i;
		b1 = a[1][1] - a1;
		
		b2 = a[1][2] - a1;
		b3 = a[1][3] - a1;
		a2 = a[2][1] - b1;
		a3 = a[3][1] - b1;
		if((a[1][1] != a1 + b1) || (a[1][2] != a1 + b2) || (a[1][3] != a1 + b3) ) f = 0;
		if((a[2][1] != a2 + b1) || (a[2][2] != a2 + b2) || (a[2][3] != a2 + b3) ) f = 0;
		if((a[3][1] != a3 + b1) || (a[3][2] != a3 + b2) || (a[3][3] != a3 + b3)) f = 0;
	}

	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;







	return 0;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
lst = [int(input()) for i in range(q)]

seikai = [0]*n

for i in lst:
    seikai[i-1] += 1

for j in seikai:
    if k - (q-j) <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 13580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N	200000
#define INF	0x3f3f3f3f3f3f3f3fLL

long long min(long long a, long long b) { return a < b ? a : b; }

void update(long long *ft, int i, int n, long long x) {
	while (i < n) {
		ft[i] = min(ft[i], x);
		i |= i + 1;
	}
}

long long query(long long *ft, int i) {
	long long x = INF;

	while (i >= 0) {
		x = min(x, ft[i]);
		i &= i + 1, i--;
	}
	return x;
}

int main() {
	static long long dp[N], ft1[N], ft2[N];
	int n, q, i, j;
	long long d, ans;

	scanf("%d%d%d%d", &n, &q, &i, &j), i--, j--;
	memset(ft1, 0x3f, n * sizeof *ft1);
	memset(ft2, 0x3f, n * sizeof *ft2);
	update(ft1, j, n, -j);
	update(ft2, n - 1 - j, n, j);
	d = 0;
	while (q--) {
		int i_;
		long long x;

		scanf("%d", &i_), i_--;
		d += abs(i - i_);
		x = min(query(ft1, i_) + i_, query(ft2, n - 1 - i_) - i_) - abs(i - i_);
		dp[i] = min(dp[i], x);
		update(ft1, i, n, x - i);
		update(ft2, n - 1 - i, n, x + i);
		i = i_;
	}
	ans = INF;
	for (i = 0; i < n; i++)
		ans = min(ans, dp[i]);
	ans += d;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6412
#include <cstdio>
#include <iostream>

const int MAXN = 200000;

using namespace std;

int N, ans = 0;
int a[MAXN];

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

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

    for (int i = 1; i <= N; ++i) {
        if (a[a[i]] == i)
            ++ans;
    }

    printf("%d", ans/2);

    return 0;
}


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

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int num = 0;
    while (a[i] % 2 == 0) {
      num++;
      a[i] /= 2;
    }
    ans += num;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
h,w,k = map(int,input().split())
c = []
for i in range(h):
    s = input()
    c.append(s)
def dfs(i,a,b):
    if i == h+w:
        count = 0
        for j in range(h):
            if a[j] == 0:
                continue
            for l in range(w):
                if b[l] == 0:
                    continue
                if c[j][l] == '#':
                    count+=1
        if count == k:
            return 1
        else:
            return 0
    if i<h:
        d = a.copy()
        d[i]+=1
        return dfs(i+1,a,b) + dfs(i+1,d,b)
    else:
        d = b.copy()
        d[i-h]+=1
        return dfs(i+1,a,b) + dfs(i+1,a,d)
tmp1 = [0 for i in range(h)]
tmp2 = [0 for i in range(w)]
print(dfs(0,tmp1,tmp2))

Measured memory_bytes: 68520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
    a = max(a,b);
}

int main()
{
    string s,t; cin >> s >>t;
  	int count =0;
  	for(int i=0;i<3;i++){
    	if(s[i] == t[i]) ++count;
    }
	cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void swap(ref char lhs, ref char rhs)
        {
            char tmp = lhs;
            lhs = rhs;
            rhs = tmp;
        }

        static void Main(string[] args)
        {
            for (; ; )
            {
                var input = Console.In.ReadLine();
                if (input == "-")
                {
                    break;
                }

                var deck = input.ToCharArray();
                var shuffleCount = int.Parse(Console.In.ReadLine());

                for (int iShuffle = 0; iShuffle < shuffleCount; ++iShuffle)
                {
                    var h = int.Parse(Console.In.ReadLine());
                    for (int i = 0; i < h; ++i)
                    {
                        for (int j = 0; j < deck.Length - 1; ++j)
                        {
                            swap(ref deck[j], ref deck[j + 1]);
                        }
                    }
                }

                var output = string.Join("", deck);
                Console.Out.WriteLine(output);
            }
        }
    }
}



Measured memory_bytes: 17984
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long int LL;
typedef pair<int, int> PII;

int main(void){
  LL n, a, b;

  cin >> n >> a >> b;

  if (b < a) {
    cout << 0 << endl;
    return 0;
  }

  if (n == 1) {
    if (a == b) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    cout << (n - 2) * (b - a) + 1 << endl;
  }

  return 0;
}

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

/* 幅優先探索。dequeをキューとして使う。ABC007/c とほぼ同じ。(盤面の"."の数 - 最短歩数 - 1) で答えが求まる。*/
int main(void){
    int H,W;
    cin >> H >> W;
    char board[H][W];
    deque<tuple<int, int, int>> will_search;
    int dot_count = 0;
    rep(i,H){
        rep(j,W){
            cin >> board[i][j];
            if(board[i][j] == '.')dot_count++;
        }
    }
    will_search.emplace_back(make_tuple(0,0,0));
    board[0][0] = '#';
    const int DIRECTION_NUM = 4;
    const int dx[DIRECTION_NUM] = {1, -1, 0, 0};
    const int dy[DIRECTION_NUM] = {0, 0, 1, -1};
    while(!will_search.empty()){
        tuple<int, int, int> current_location = will_search.front();
        will_search.pop_front();
        rep(i,DIRECTION_NUM){
            int next_y = get<0>(current_location) + dy[i];
            int next_x = get<1>(current_location) + dx[i];
            int step = get<2>(current_location) + 1;
            if(next_x >= 0 && next_x < W && next_y >= 0 && next_y < H){
                if(board[next_y][next_x] == '.'){
                    will_search.emplace_back(make_tuple(next_y, next_x, step));
                    board[next_y][next_x] = '#';
                }
                if(next_x == W-1 && next_y == H-1){
                    cout << dot_count - step - 1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1" << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int a[100];
	for (int i = 0; i < 3; i++)
		{
		cin >> a[i];
}
	for (int i = 0; i < 3; i++)
	{
		if (i != 0)
		{
			if (a[i - 1] != a[i])
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;



}

Measured memory_bytes: 256
#include<stdio.h> 

int main(void){

    long long int H,i,ans = 0,based_num = 1;

    scanf("%lld",&H);

    while(based_num*2 <= H){
        based_num *= 2;
    }

    H = based_num;

    while(H/2 != 0){
        ans += H;
        H /= 2;
    }

    printf("%lld\n",ans+1);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define   ll long long int
#define maxn 300005


int diff(string s,string t){
int ans=0;
for(int i=0;i<s.length();i++){
    ans+=s[i]!=t[i];
}
return ans;
}
int main(){
string s,t;
cin>>s>>t;
int ans=10000;
for(int i=0;i<=(s.length()-t.length());i++){
    int tans=diff(s.substr(i,t.length()),t);
    ans=min(ans,tans);
}
cout<<ans<<endl;

}


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

namespace ABC171
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            char a = Console.ReadLine()[0];
            if (Char.IsUpper(a))
                Console.WriteLine("A");
            else
                Console.WriteLine("a");
        }
    }
}


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

struct shop{
	int a, b, c;

	bool operator < (const shop& s) {
		return c < s.c;
	}

};

struct Fenwick{
	int n; //Size of array
	vector<int> tree;

	void build(int m){ //Initializes the tree
		n = m;
		tree = vector<int>(m+1,0);
	}

	int read(int idx){ //Gives the sum [1,idx]
	    int sum = 0;
		idx++;
	    while (idx > 0){
	        sum += tree[idx];
	        idx -= (idx & -idx);
	    }
	    return sum;
	}

	void update(int k ,int val){ //Increases the k-th value
		k++;
	    while (k <= n){
	        tree[k] += val;
	        k += (k & -k);
	    }
	}
};

shop v[300010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i){
		cin >> v[i].a >> v[i].b;
		++v[i].b;
		v[i].c = v[i].b - v[i].a;
	}
	sort(v, v+n);
	Fenwick F;
	F.build(m+1);
	int it = 0;
	for(int i = 1; i <= m; ++i){
		while(it < n and v[it].c < i) {
			F.update(v[it].a, 1);
			F.update(v[it].b, -1);
			++it;
		}
		int cur = n - it;
		for(int j = 1; j * i <= m; ++j) cur += F.read(j*i);
		cout << cur << endl;
	}
}


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

using namespace std;

int main()
{
    int max1=-1000,min1=1000,mn=1000000000,m,n,arr[1000];
    map<int,int>maps;
    set<int>sets;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sets.insert(arr[i]);
        maps[arr[i]]++;
        min1=min(min1,arr[i]);
        max1=max(max1,arr[i]);
    }

        for(int i=min1;i<=max1;i++){
                int m=0;
            for(auto p:sets){
                m+=(((i-p)*(i-p))*maps[p]);
        }
        mn=min(mn,m);
    }
    cout<<mn<<endl;

    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    if (s.count(a) == 0) {
      s.insert(a);
    }
  }

  cout << s.size() << endl;
  return 0;
}

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

#define X first
#define Y second
#define mp make_pair
#define pb pop_back
#define eb emplace_back
#define sz(v) (int) v.size()

using namespace std;

typedef long long LL;
typedef long double LD;

void solve() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; ++i) {
		cout << i << " ";
	}
	cout << "\n";
}

signed main() {
// #define TASK ""
#if !defined(LOCAL) && defined(TASK)
	// freopen(TASK".in", "r", stdin);
	// freopen(TASK".out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		solve();
	}
	return 0;
}

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

ll mul(ll a, ll b) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) {
            r = (r + a) % mod;
        }
        a = (a + a) % mod;
        b /= 2;
    }
    return r;
}

ll power(ll x, ll n) {
    ll res = 1;
    x %= mod; 
    while (n > 0)  
    {  
        if (n & 1)  res = (res*x)%mod;  
        n = n>>1; 
        x = (x*x)%mod;  
    }  
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    ll L;
    cin >> L;
    double a = (double)L/3;
    double ans = a*a*a;
    printf("%.9f\n", ans);
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
H=list(map(int,input().split()))

DPLIST=[float("inf")]*N
DPLIST[0]=0

for i in range(N-1):
    for j in range(1,K+1):
        if i+j<N:
            DPLIST[i+j]=min(DPLIST[i+j],DPLIST[i]+abs(H[i+j]-H[i]))

print(DPLIST[N-1])

Measured memory_bytes: 55264