akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <deque>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;


vector<int> mati;
const ll INF=1LL<<50;
struct Edge {
  ll to, cost;
  Edge(ll a, ll b){to=a;cost=b;}
};
vector<vector<Edge> > graph;
vector<ll> dist;

/* num of vertex is 'n', start at 's' */
bool bellman_ford(ll n, ll s) {
  dist.clear();
  dist.resize(n, INF);
  dist[s] = 0;
  for (ll i = 0; i <= n; i++) {
    for (ll v = 0; v < n; v++) {
      for (ll k = 0; k < graph[v].size(); k++) {
	Edge e = graph[v][k];
	if(dist[v]==INF) continue;
	if (dist[e.to] > dist[v] + e.cost) {
	  dist[e.to] = dist[v] + e.cost;
	  if (i == n) return true; /* detect cycle */
	}
      }
    }
  }
  return false;
}


int main(void){
  int n,m,r;
  cin>>n>>m>>r;
  int x,a,b,c;
  for(int i=0;i<r;i++){
    cin>>x;
    mati.pb(x-1);
  }
  graph.resize(n);
  
  for(int i=0;i<m;i++){
    cin>>a>>b>>c;
    graph[a-1].pb(Edge(b-1,c));
    graph[b-1].pb(Edge(a-1,c));
  }
  
  vector<vector<ll> > waro(n);
  for(int i=0;i<n;i++){
    bellman_ford(n,i);
    waro[i]=dist;
  }
  /*
  cout<<endl;
  for(int i=0;i<n;i++){
    cout<<i<<":";
    for(int j=0;j<waro[i].size();j++){
      cout<<waro[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  
  ll res=INF;
  sort(mati.begin(),mati.end());
  
  do{
    ll tmp=0;
    for(int i=1;i<mati.size();i++){
      tmp+=waro[mati[i-1]][mati[i]];
    }
    
    res=min(tmp,res);
  }while(next_permutation(mati.begin(),mati.end()));
  cout<<res<<endl;
  
  return 0;
}



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

const int N = 10000;

bool dp[2][N+N], tmp[N+N];

void modify(int dir, int cnt) {
  memset( tmp, 0, sizeof(tmp));
  for (int i = 0; i < N+N; i++) {
    if ( dp[dir][i] ) {
      tmp[i-cnt] = 1;
      tmp[i+cnt] = 1;
    }
  }
  for (int i = 0; i < N+N; i++) dp[dir][i] = tmp[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int x, y;
  cin >> s >> x >> y;
  s += 'T';
  int n = s.length(), dir = 0; // x-axis
  dp[0][N] = dp[1][N] = 1;
  bool start = 1;
  for ( int i = 0, cnt = 0; i < n; i++) {
    if ( start && s[i] == 'F' ) {
      dp[0][N+i+1] = 1;
      dp[0][N+i] = 0;
      continue;
    }
    else start = 0;
    if ( s[i] == 'T' ) {
      modify( dir, cnt );
      cnt = 0;
      dir ^= 1;
    }
    else {
      cnt++;
    }
  }
  if ( dp[0][N+x] && dp[1][N+y] ) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

int main() {
  char a,b,c,d,e,f,g,h,i;
  cin >> a>>b>>c>>d>>e>>f>>g>>h>>i;
 
  cout<<a<<e<<i<<endl;
 
}

Measured memory_bytes: 256
(let* ((h (read))
       (w (read))
       (lst (loop repeat h
                  collect (string-downcase (symbol-name (read))))))

  (format t "~{~A~}~%"
          (make-list (+ w 2) :initial-element #\#))

  (format t "~{#~A#~%~}"
          lst)

  (format t "~{~A~}~%"
          (make-list (+ w 2) :initial-element #\#)))


Measured memory_bytes: 6624
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define pri(str) cout << str << endl
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int n; cin >> n;
    ll mx = 0;
    ll step = 0;
    rep(i,n)
    {
        ll a; cin >> a;
        if( a < mx )
        {
            step += (mx-a);
        }
        else
        {
            mx = a;
        }
    }
    pri(step);
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,a[200005],mi,len;vector<pii> v;
void add(int x,int c){
    len+=c;
    if(!v.empty()&&v.back().fi==x) v.back().se+=c;
    else v.pb(mpr(x,c));
}
void clear(){if(!v.empty()&&v.back().se==0) v.pop_back();}
bool check(int x){
    v.clear();len=0;
    rep(i,1,n){
        int c=a[i];
        if(a[i]>len) add(0,c-len);
        else {
            while(len-v.back().se>=c&&v.size()>0) len-=v.back().se,v.pop_back();
            v.back().se=c-(len-v.back().se);len=c;
            while(v.size()>0&&v.back().fi==x-1) len-=v.back().se,v.pop_back();
            if(v.empty()) return 0;
            v.back().se--;
            int w=v.back().fi+1;
            clear();
            add(w,1);len--;
            add(0,c-len);
            clear();

            //rap(i,0,v.size()) printf("%d %d\n",v[i].fi,v[i].se);
            //putchar('\n');
        }
    }
    return 1;
}
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i);
    int l=1,r=n;
    //check(2);
    while(l<r){
        int mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    printf("%d\n",l);
    return 0;
}

Measured memory_bytes: 1152
n=int(input())

comment=[]
for i in range(n):
    a=int(input())
    
    for _ in range(a):
        x,y = map(int,input().split())
        comment.append([i,x-1,y])

ans = 0

for bit in range(2**n):
    
    for s in comment:
        if (bit>>s[0])&1 == 1:
            if (bit>>s[1])&1 != s[2]:
                break
    else:
        tmp = str(bin(bit)).count("1")
        ans=max(ans,tmp)
print(ans)
        

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
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);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	REP(i, (int)s.size()) if (s[i] == 'o') ans++;
	if (8 <= 15-(int)s.size() + ans) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

// ***************************************

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

vector<vector<int>> B, F;

int main() {

    int N, M, K;

    cin >> N >> M >> K;

    UnionFind uf(N);
    vector<set<int>> dame(N);

    int a, b;
    REP(i, M) {
        cin >> a >> b;
        dame[a - 1].insert(b - 1);
        dame[b - 1].insert(a - 1);
        uf.merge(a - 1, b - 1);
    }

    REP(i, K) {
        cin >> a >> b;
        if (!uf.issame(a-1, b-1)) continue;
        dame[a - 1].insert(b - 1);
        dame[b - 1].insert(a - 1);
    }

    REP(i, N) {
        cout << uf.size(i) - dame[i].size() - 1 << " ";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 24704
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  int a[n];
  long long int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum=sum^a[i];
  }
  for(int i=0;i<n;i++)
  {
    cout<<(sum^a[i])<<" ";
  }
  return 0;
}

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

int main(void)
{
  int a[101],n,i,max;
  for(i=1;i<=100;i++)
    a[i]=0;
  while(scanf("%d",&i)!=EOF){
    a[i]++;
  }
  max=0;
  for(i=1;i<=100;i++){
    if(a[i]>max)
      max=a[i];
  }

  for(i=1;i<=100;i++)
    if(a[i]==max)
      printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define mod 1000000009
using namespace std;

long long a,b,c,k;

int main(){
	cin >> a >> b >> c >> k;
	if(k % 2 == 0){
		cout << a - b << "\n";
	}else{
		cout << b - a << "\n";
	}

}

Measured memory_bytes: 256
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        Node nodes[] = new Node[n];
        for (int i=0; i<n; i++) nodes[i] = new Node();
        for (int i=0; i<n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            nodes[a].neighbors.add(nodes[b]);
            nodes[b].neighbors.add(nodes[a]);
        }

        for (int i=0; i<q; i++){
            int p = sc.nextInt()-1;
            nodes[p].offset += sc.nextInt();
        }

        dfs(null, nodes[0], 0);
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n; i++){
            sb.append(nodes[i].counter).append(" ");
        }
        System.out.println(sb.toString());


    }

    private static void dfs(Node parent, Node node, int sum){
        sum += node.offset;
        node.counter = sum;
        for (Node n: node.neighbors){
            if (n != parent){
                dfs(node, n, sum);
            }
        }
    }


    private static class Node{
        private List<Node> neighbors = new ArrayList<>();
        private int offset;
        private int counter;
    }
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    ll alice = 0, bob = 0;
    for(int i = 1; n - i >= 0; ++i){
        if(i % 2 == 1){
            alice += a.at(n - i);
        }else{
            bob += a.at(n - i);
        }
    }
    cout << alice - bob << endl;
    return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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; }

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    vector<int> s; // s[i]:iの属する木のノード数
    int n_group; // 木の数
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
        s.assign(N, 1);
        n_group = N;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[ry] += s[rx];
        s[rx] = 0;
        n_group--;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }

    int size(int x){ // xが属する木のノード数
        return s[root(x)];
    }
};

int main(void){
    int N,M; cin >> N >> M;
    UnionFind uf(N+M);
    REP(i,N){
        int K; cin >> K;
        REP(j,K){
            int L; cin >> L; L--;
            uf.unite(i,L+N);
        }
    }

    REP(i,N){
        if(!uf.same(0,i)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main()
{
   int n, i, count = 0;
   scanf("%d", &n);
   int a[n], b[n];
   for (i = 0; i < n; i++)
      scanf("%d%d", &a[i], &b[i]);

   for (i = 0; i < n; i++)
   {
      if (a[i] == b[i])
         count++;
      else
         count = 0;
      if (count == 3)
      {
         printf("Yes");
         return 0;
      }
   }
   printf("No");
}

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

int main(){
char a[1000],b[1000],a1[1000],b1[1000],r='a';
int c,k,w;
scanf("%s\n",a);
 scanf("%s",b);
 sort(a,a+strlen(a));
 sort(b,b+strlen(b));
if(a[0]<b[strlen(b)-1]){
	cout<<"Yes";
	return 0;
}
if(strcmp(a,b)<0){
	cout<<"Yes";
}
else{
	cout<<"No";
}
	return 0;
} 








Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;
  cin >> n;

  vector<ll>  A(n);
  rep(i, n) cin >> A[i];
  sort(A.begin(), A.end());

  ll ans = 0;
  rep(i, n - 1) ans += A[n - 1 - (i + 1) / 2];

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


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(3,0);
    rep(i,n){
        cnt[a[i]%3]++;
    }
    if(cnt[1]==0 and cnt[2]==0){
        cout << 1 << "\n";
    }else{
        int ans = cnt[0];
        ans += min(cnt[1],cnt[2]) * 2;
        ans += min(3,max(cnt[1],cnt[2])-min(cnt[1],cnt[2]));
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 4672
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<P> V[16];
main(){
    int N;
    cin >> N;
    rep(i,0,N){
        int A;
        cin >> A;
        rep(j,0,A){
            int x,y;
            cin >> x >> y;
            x--;
            V[i].emplace_back(x, y);
        }
    }
    int maxi = 0;
    rep(i,0,1 << N){
        vector<int> truth(N);
        vector<int> vec(N);
        rep(j,0,N){
            vec[j] = -1;
            if(i & (1 << j)){
                truth[j] = 1;
            }else{
                truth[j] = 0;
            }
        }
        bool ok = 1;
        rep(j,0,N){
            if(!truth[j])continue;
            for(auto p:V[j]){
                int pre = vec[p.first];
                if(p.second)vec[p.first] = 1;
                else vec[p.first] = 0;

                if(pre != -1 && pre != vec[p.first])ok = 0;
            }
        }
        
        rep(j,0,N){
            if(vec[j] != -1 && truth[j] != vec[j]){
                ok = 0;
                break;
            }
        }
        
        if(!ok)continue;
        maxi = max(maxi, __builtin_popcount(i));

        //cout << i << endl;
        //rep(j,0,N)cout << vec[j] << " \n"[j==N-1];
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var nums = new int[N];
            for (int i = 0; i < nums.Length; i++)
            {
                nums[i] = int.Parse(Console.ReadLine());
            }

            var result = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                if (IsPrimeNum(nums[i])) result++;
            }

            Console.WriteLine(result);
        }

        private static bool IsPrimeNum(int p)
        {
            var num = Math.Sqrt(p);
            for (int i = 2; i <= num; i++)
            {
                if ((p % i) == 0) return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;

int n, m;
vector<int> edg[MAXN];
int sumb = 0, numb = 0, sumn = 0, numn = 0;
int col[MAXN], size[MAXN];
long long ans = 0;

bool dfs(int x, int fa, int c)
{
	if(col[x] != -1)
		return col[x] == c;
	col[x] = c;
	size[x] = 1;
	bool ret = true;
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i] != fa)
		{
			int y = edg[x][i];
			if(col[y] == -1)
				ret &= dfs(y, x, c ^ 1), size[x] += size[y];
			else
				ret &= dfs(y, x, c ^ 1);
		}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y), edg[y].push_back(x);
	}

	memset(col, -1, sizeof(col));
	for(int i = 1; i <= n; i++)
		if(col[i] == -1)
		{
			bool flag = dfs(i, 0, 0);
			int sz = size[i];
			if(sz > 1)
			{
				if(flag)
					sumb += sz, numb += 1;
				else
					sumn += sz, numn += 1;
			}
		}
	// cerr << sumb << ' ' << sumn << endl;
	ans = (long long)n * n;
	ans -= (long long)(sumb + sumn) * (sumb + sumn);
	ans += (long long)(numb + numn) * (numb + numn) + (long long)numb * numb;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12288
N,K=map(int,input().split())

D=[]
A=[]
for i in  range(K):
    D.append(int(input()))
    A.append(list(map(int,input().split())))

S=[]
for i in range(K):
    S+=A[i]

s=set(S)

total=0
for i in range(1,N+1):
    if (i in s)==False:
        total+=1
print(total)

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

int main() {
	int h,w,i,j;
	while(cin>>h>>w,h) {
		for(i=0;i<h;i++) {
			for(j=0;j<w;j++) {
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	if s == "25" {
		fmt.Println("Christmas")
	}
	if s == "24" {
		fmt.Println("Christmas Eve")
	}
	if s == "23" {
		fmt.Println("Christmas Eve Eve")
	}
	if s == "22" {
		fmt.Println("Christmas Eve Eve Eve")
	}
}



Measured memory_bytes: 640
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
if n==m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 440

int n, m, ans;
bool f[AC][AC];

inline int read()
{
	int x = 0;char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

void pre(){
	n = read(), m = read();	
}

void work()
{
	for(R i = 1; i <= m; i ++)
	{
		int x = read(), y = read();
		if(f[y][y] || f[x][x]) //这一切的前提都是自己要活着。。。。
		{
			f[x][x] = f[y][y] = true;
			continue;
		}
		for(R j = 1; j <= n; j ++) 
			if(f[x][j])	f[y][j] = f[j][y] = true;//找到y需要连哪些边
		for(R j = 1; j <= n; j ++) 
			if(f[y][j]) f[x][j] = f[j][x] = true;
		f[x][y] = f[y][x] = true;
	}
	
	for(R i = 1; i <= n; i ++)
		for(R j = i + 1; j <= n; j ++) 
			if(!f[i][j] && !f[j][j] && !f[i][i]) ++ ans;//需要两者都不是必须死的，而且没有不能共存的限制
	printf("%d\n", ans);
}

int main()
{
	//freopen("in.in", "r", stdin);
	pre();
	work();
	//fclose(stdin);
	return 0;
}


Measured memory_bytes: 384
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W, K = in.next().toInt
  val s = new Array[String](H)
  for (i <- 0 until H) {
    s(i) = in.next()
  }


  //
  var color = 1
  var flag = false
  var rowFlag = false
  var rowVol = 1
  var ans = Array.ofDim[Int](H, W)
  for (y <- 0 until H) {
    for (x <- 0 until W) {
      if (s(y)(x) == '#') {
        rowFlag = true

        if (!flag) {
          flag = true
        }
        else {
          color += rowVol
          rowVol = 1
        }
      }

      ans(y)(x) = color
    }


    // カラー潰し
    if (!rowFlag) {
      for (x <- 0 until W) {
        ans(y)(x) = -1
      }
    }


    // 折り返し
    if (rowFlag && color != K) {
      if (rowVol == 1)
        color += 1

      rowVol = 0
    }

    rowFlag = false
  }



  // 塗り分け
  for (x <- 0 until W) {
    var hoge = -1
    for (y <- 0 until H) {
      if (ans(y)(x) == -1)
        ans(y)(x) = hoge
      else {
        hoge = ans(y)(x)
      }
    }
  }

  for (x <- 0 until W) {
    var hoge = -1
    for (y <- (0 until H).reverse) {
      if (ans(y)(x) == -1)
        ans(y)(x) = hoge
      else {
        hoge = ans(y)(x)
      }
    }
  }



  // print
  for (y <- 0 until H) {
    pw.println(ans(y).mkString(" "))
  }

  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main(){
    int h,w;
    cin >> h >> w;
    string S[h];
    for(int i = 0; i < h; i++){
        cin >> S[i];
    }
    for(int i = 0; i < h+2; i++){
        if(i == 0 || i == h+1){
            for(int j = 0; j < w+2; j++){
                cout << '#';
            }
            cout << endl;
        }else{
            cout << "#" << S[i-1] << "#" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
// AOJ 1084: K Cards
// 2018.2.3 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int n, k, m;
int c[101];

int check()
{
	int i, j, t, max = 0;

	for (i = 0; i <= m; i++) {
		t = c[i];
		for (j = 1; j < k; j++)	t *= c[i+j];
		if (t > max) max = t;
	}
	return max;
}

int main()
{
	int i, j, x, t, max0, max;

	while (n = in()) {
		k = in(), m = n-k;
		for (i = 0; i < n; i++) c[i] = in();

		max0 = check();
		max = 0;
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			x = c[i], c[i] = c[j], c[j] = x;
			t = check();
			if (t > max) max = t;
			x = c[i], c[i] = c[j], c[j] = x;
		}
		max -= max0;
		if (max >= 0) printf("%d\n", max);
		else puts("NO GAME");
	}
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))

using namespace std;
void get(int &v)
{
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return ;
}
int get()
{
	int v;
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return v;
}
priority_queue<long long>q;
stack<long long>s;
long long chk(int sz)
{
	long long ans=0,t,tmp;
	while(q.top()>=sz)
	{
		t=q.top();
		q.pop();
		ans+=(tmp=t/sz);
		while(q.size())
		{
			s.push(q.top()+tmp);
			q.pop();
		}
		while(s.size())
		{
			q.push(s.top());
			s.pop();
		}
		q.push(t%sz);
	}/*
	while(q.size())
		cout<<q.top()<<' ',q.pop();
	cout<<endl;*/
	return ans;
}
int main()
{
	int n,i;
	long long x;
	get(n);
	for(i=1;i<=n;i++)
	{
		cin>>x;
		q.push(x);
	}
	cout<<chk(n);
	return 0;
}
//g++ -g cc.cpp -o cc

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

using namespace std;

#define FAST_IO ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
typedef long long ll;
 
int main(){ 
	
	FAST_IO;
   
	ll n,W;
	cin>>n>>W;

	ll w[n],v[n];
	for(ll i=0; i<n; i++){
		cin>>w[i]>>v[i];
	}

	ll dp[W+1] ={0};

	for(ll i=0; i<n; i++){
		for(ll j=W; j>=0; j--){
			if(w[i]<=j)
				dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}

	cout<<dp[W]<<endl;
}
 

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

using namespace std;
typedef long long ll;

int main(){
	int q;
	cin >> q;
	ll sum = 0;
	while(q--){
		ll p, n;
		string c;
		cin >> p >> c >> n;
		if(c[0] == '('){
			sum += n;
		}else{
			sum -= n;
		}
		cout << (sum == 0 ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int num1 = n - h + 1;
        int num2 = n - w + 1;
        System.out.println(num1 * num2);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    map<string, ll> cnt;

    rep(i, n){
        string s; cin >> s;
        cnt[s]++;
    } 

    string labels[] = {"AC", "WA", "TLE", "RE"};
    for(string label : labels){
        cout << label << " x " << cnt[label] << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int judge(char left[],char s[]){
    int i,j,count=0,k=0;
    for(i=0;left[i]!=0;i++)
        if(left[i]==s[0])
            k=1;
   
    for(j=1;s[j]!=0;j++)
        for(i=0;left[i]!=0;i++){
            if(left[i]==s[j]){
           
                if(k==0){
                count++;
           
                k=1;
                }
                break;
            }
            else{
                if(k==1&&i==14){
                    count++;
     
                    k=0;
                }
            }
        }
    return count;
}
int main(void){
    char s[100],left[]="qwertasdfgzxcvb";
    
    while(1){
        scanf("%s",s);
        if(s[0]=='#')
            break;
        printf("%d\n",judge(left,s));
    }
    return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  string s, t={};
  c(s);
  int a=0;
  rep(i,0,s.size()/2){
    t+=s[i*2];
  }
  if(s.size()%2==1) t+=s[s.size()-1];
  co(t);
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    vector<vector<int>>a(3,vector<int>(3,0));
    int sum=0,check=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a.at(i).at(j);
            if(i==j)check+=a.at(i).at(j);
            sum+=a.at(i).at(j);
        }
    }
    if(sum==3*check)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define REP(A, H) for(int A = 0; A < H; A++)
#define REP1(A, H) for(int A = 1; A < H; A++)
#define ALL(c) c.begin(), c.end()
#define SHOWL(c) std::cout << c << std::endl
#define SHOW(c) std::cout << c
#define CIN std::cin 
#define COUT std::cout
#define EL std::endl
#define CIN std::cin
#define VEC std::vector
#define P std::pair
#define MKP std::make_pair

typedef long long ll;

bool cmp(const P<ll, ll>& a, const P<ll, ll>& b) {
  return a.first < b.first;
}

int main(void) {
  int n, m; CIN >> n >> m;
  VEC< P<ll, ll> > abs(n);

  REP(i, n) {
    ll a, b; CIN >> a >> b;
    abs[i] = MKP(a, b);
  }

  std::sort(ALL(abs), cmp);

  ll mon = 0;
  ll cnt = 0;
  ll i = 0;
  while(cnt <= m) {
    cnt += abs[i].second;
    mon += abs[i].second * abs[i].first;
    i++;
  }
  
  //COUT << mon << " " << cnt << " " << i <<  " " << EL;

  ll res = mon - (cnt - m) * abs[i - 1].first;

  SHOWL(res);

  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
  int n,s,g,i;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&s,&g);
    if(s<=5&&g<=5){
      if(s<g){
	for(i=s;i<g;i++)
	  printf("%d ",i);
	printf("%d\n",g);
      }
      else{
	for(i=s;i>g;i--)
	  printf("%d ",i);
	printf("%d\n",g);
      }
    }
    else if(s>g&&g>=6){
      for(i=s;i<=9;i++)
	printf("%d ",i);
      for(i=5;i>0;i--)
	printf("%d ",i);
      for(i=0;i<g;i++)
	printf("%d ",i);
      printf("%d\n",g);
    }
    else{
      if(s<g){
	for(i=s;i<g;i++)
	  printf("%d ",i);
	printf("%d\n",g);
      }
      else{
	for(i=s;i<=9;i++)
	  printf("%d ",i);
	for(i=5;i>g;i--)
	  printf("%d ",i);
	printf("%d\n",g);
      }
    }
  }
  return 0;
}

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

int main() {
	int N;
	bool flag = false;
	cin >> N;
	vector<char> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		if (S[i] == 'Y') {
			flag = true;
		}
	}
	if (flag)cout << "Four" << endl;
	else cout << "Three" << endl;
}

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

typedef pair<int, int> ShopDrinknumAndDrinkprice;
int ShopDrinknumAndDrinkprice::* price = &ShopDrinknumAndDrinkprice::first;
int ShopDrinknumAndDrinkprice::* num = &ShopDrinknumAndDrinkprice::second;


int main() {
    int N, M; cin >> N >> M;
    vector<ShopDrinknumAndDrinkprice> ShopInfo(N);
    for (int i = 0; i < N; i++) {
        int A, B; cin >> A >> B;
        ShopInfo[i].*price = A;
        ShopInfo[i].*num = B;
    }
    sort(ShopInfo.begin(), ShopInfo.end());  // Sort by price.

    long long ans = 0;
    int totalNum = 0;
    for (int shopId = 0; shopId < N; shopId++) {
        int p = ShopInfo[shopId].*price;
        int n = ShopInfo[shopId].*num;
        ans += (long long)p * (long long)n;
        totalNum += n;
        if (totalNum >= M) {
            ans -= ((long long)totalNum - (long long)M) * (long long)p;
            break;
        }
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[100001];
int n,m,k;
ll dp[100001][301];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m>>k;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	for(int i = 0; i < n; i++)
	{
		dp[i][1] = a[i];
	}
	ll sum = a[0];
	for(int j = 2; j <= k; j++)
	{
		deque<ll> dq;
		dp[j-1][j] = sum+ll(j)*a[j-1];
		sum=dp[j-1][j];
		for(int z = 0; z < j; z++)
		{
			while(!dq.empty()&&dp[dq.back()][j-1]<=dp[z][j-1]) dq.pop_back();
			dq.push_back(z);
		}	
		for(int i = j; i < n; i++)
		{
			dp[i][j] = ll(j)*a[i] + dp[dq.front()][j-1];
			while(!dq.empty()&&dp[dq.back()][j-1]<=dp[i][j-1]) dq.pop_back();
			dq.push_back(i);
			while(!dq.empty()&&i-dq.front()>=m) dq.pop_front();
		}
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) ans = max(ans, dp[i][k]);
	cout<<ans<<'\n';
}


Measured memory_bytes: 236288
s = input().strip()


def is_palindrome(string):
    return string == string[::-1]


def is_strong_palindrome(string):
    if not is_palindrome(string):
        return False
    n = len(string)
    if not is_palindrome(string[:(n - 1)//2]):
        return False
    if not is_palindrome(string[(n+3)//2 - 1:]):
        return False
    return True


if is_strong_palindrome(s):
    print('Yes')
else:
    print('No')


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

int main() {
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(A>=K){
    cout<<K<<endl;
  }
  else if(A+B>=K){
    cout<<A<<endl;
  }
  else{
    cout<<2*A+B-K<<endl;
  }
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s;
    cin >> t;
    int ssize = s.size(), tsize = t.size();
    vector<vector<int> > A(26);
    for (int i = 0; i < ssize; i++) {
        A[s[i]-'a'].push_back(i);
    }
    vector<int> N(tsize);
    if (A[t[0]-'a'].empty()) {
        printf("-1\n");
        return 0;
    } else {
        N[0] = *A[t[0]-'a'].begin();
    }
    for (int i = 1; i < tsize; i++) {
        int abc = t[i]-'a';
        auto it = upper_bound(A[abc].begin(), A[abc].end(), N[i-1]);
        if (it == A[abc].end()) {
            if (A[abc].empty()) {
                printf("-1\n");
                return 0;
            }
            N[i] = *A[abc].begin();
            ans += ssize;
        } else {
            N[i] = *it;
        }
    }
    ans += N[tsize-1]+1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1488
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL S,C;
	cin >> S >> C;
	LL ans = 0;
	LL res = min(S,C/2);
	ans += res;
	S -= res;
	C -= res*2;
	res = C/4;
	ans += res;
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int sum = 0;
		for (int i = 1; i <= round(n / 2); i++) {
			int a = 0,j=i;
			while (a < n) {
				a += j;
				j++;
			}
			if (a == n) sum++;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3196
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        親が同じか判別する
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        yをxの根に繋ぐ
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """
        xとyが同じ連結成分か判別する
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        xの連結成分の大きさを返す
        """
        return -self.parents[self.find(x)]

    def kruskal(self, edge):
        """
        :param edge: edge = [(コスト, 頂点1, 頂点2),...]の形で重み付き隣接リストを渡して下さい
        :return: 最小全域木のコストの和
        """
        edge.sort()
        cost_sum = 0
        for cost, node1, node2 in edge:
            if not self.same(node1, node2):
                cost_sum += cost
                self.union(node1, node2)
        return cost_sum


def resolve():
    n, m, k = map(int, input().split())
    uf = UnionFind(n)
    edge = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
        uf.union(a - 1, b - 1)

    block = [[] for _ in range(n)]
    for _ in range(k):
        c, d = map(int, input().split())
        block[c - 1].append(d - 1)
        block[d - 1].append(c - 1)

    res = []
    for i in range(n):
        cnt = uf.size(i) - len(edge[i]) - 1
        for j in block[i]:
            if uf.same(i, j):
                cnt -= 1
        res.append(cnt)
    print(*res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 51400
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 0408
 *  2020/5/6
 */
public class Main {

    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        
        int L = sc.nextInt();
        int[] f = new int[100];
        List<Integer> list = new ArrayList<>();
        
        for(int i = 0;; i++) {
            if (i >= L) {
                result.printf("OK\n");
                break;
            }
            int c = sc.nextInt();
            if (c > 0) {
                if (f[c - 1] > 0) {
                    result.printf("%d\n", i + 1);
                    break;
                }
                list.add(c);
                f[c - 1] = 1;
            }
            else {
                int r = -1;
                if (list.size() > 0)
                    r = list.remove(list.size() - 1);
                if (-c != r) {
                    result.printf("%d\n", i + 1);
                    break;
                }
                f[-c - 1] = 0;
            }
        }

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 30532
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[1<<11][55][55];
struct beet{
  Int b,x,y,c;
  beet(int b,int x,int y,int c):b(b),x(x),y(y),c(c){}
  bool operator<(const beet &a)const{
    return c>a.c;
  }
};
signed main(){
  Int INF=1e9;
  Int n,m;
  while(cin>>n>>m,n){
    //cout<<n<<" "<<m<<endl;
    vector<Int> d(n,0),e(n,0);
    for(Int i=1;i<n-1;i++) cin>>d[i]>>e[i];
    e[n-1]=1000;
    map<Int,Int> sz;
    vector<Int> r(n);
    for(Int i=0;i<n;i++)
      r[i]=sz[e[i]]++;
    
    vector<vector<Int> > G(n,vector<Int>(n,INF));
    for(Int i=0;i<m;i++){
      Int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      G[a][b]=c;
    }
    
    for(Int i=0;i<(1<<11);i++)
      for(Int j=0;j<55;j++)
	for(Int k=0;k<55;k++)
	  dp[i][j][k]=INF;
    
    priority_queue<beet> q;
    q.push(beet(1<<r[0],0,0,0));
    dp[1<<r[0]][0][0]=0;
    
    Int ans=INF;
    
    while(!q.empty()){
      beet ei=q.top();q.pop();
      Int b=ei.b,x=ei.x,y=ei.y,c=ei.c;
      if(dp[b][x][y]<c) continue; 
      //cout<<b<<" "<<x<<" "<<y<<":"<<c<<endl;
      //dp[b][x][y]=c;
      if(x==n-1&&y==n-1&&c<ans){
	ans=c;
	break;
      }
      if(e[x]<=e[y]){
	for(Int i=0;i<n;i++){
	  if(x==i||e[x]>e[i]) continue;
	  Int nb=b*(e[x]==e[i]);
	  nb|=(e[i]>=e[y])*(1<<r[y]);
	  Int cost=G[x][i];
	  if(e[i]<=e[y]){
	    if(!((nb>>r[i])&1)) cost+=d[i];
	    nb|=1<<r[i];
	  }else cost+=d[i];
	  //cout<<nb<<" "<<i<<" "<<y<<"---"<<c+cost<<endl;
	  if(dp[nb][i][y]<=c+cost) continue;
	  q.push(beet(nb,i,y,c+cost));
	  dp[nb][i][y]=c+cost;
	}
      }
      
      if(e[y]<=e[x]){
	for(Int i=0;i<n;i++){
	  if(y==i||e[y]>e[i]) continue;
	  Int nb=b*(e[y]==e[i]);
	  nb|=(e[i]>=e[x])*(1<<r[x]);
	  Int cost=G[i][y];
	  if(e[i]<=e[x]){
	    if(!((nb>>r[i])&1)) cost+=d[i];
	    nb|=1<<r[i];
	  }else cost+=d[i];
	  //cout<<nb<<" "<<x<<" "<<i<<"---"<<c+cost<<endl;
	  if(dp[nb][x][i]<=c+cost) continue;
	  q.push(beet(nb,x,i,c+cost));
	  dp[nb][x][i]=c+cost;
	}
      }
    }
    
    if(ans>=INF) cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 54368
X = int(input())

def make_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def f(x, y):
  return x**5 - y**5 - X

Flag = True

for A in range(-120, 120):
  if Flag:
    for i in make_div(X):
      B = A - i
      if f(A, B) == 0:
        print(A, B)
        Flag = False
        break
  else:
    break


Measured memory_bytes: 9320
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(v: i64, n: i64, k: i64) -> i64 {
    if n == 0 {
        return v;
    }
    std::cmp::min(dfs(v + k, n - 1, k), dfs(v * 2, n - 1, k))
}
fn main() {
    let n: i64 = read();
    let k: i64 = read();
    println!("{}", dfs(1, n, k));
}


Measured memory_bytes: 4352
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

long N;
long Q;
std::vector<std::vector<long>> tree;
std::vector<long> value;
std::vector<long> total;
std::vector<int> arrived;

void rec(long curnode, long curval) {
	curval += value[curnode];
	total[curnode] = curval;
	arrived[curnode] = 1;

	for (auto child : tree[curnode]) {
		if (!arrived[child])
			rec(child, curval);
	}
}

int main()
{
	std::cin >> N >> Q;
	tree.resize(N);
	value.resize(N);
	total.resize(N);
	arrived.resize(N);
	for (long i = 0; i < N-1; ++i) {
		long a, b;
		std::cin >> a >> b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);
	}
	for (long i = 0; i < Q; ++i) {
		long p, x;
		std::cin >> p >> x;
		value[p-1] += x;
	}

	rec(0, 0);

	for (long i = 0; i < total.size(); ++i) {
		std::cout << total[i];
		std::cout << " ";
	}
	std::cout << "\n";
}


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

namespace ProblemD
{
    class Program
    {
        public static int div = 1000000007;
        public static Dictionary<List<int>, int> dict = new Dictionary<List<int>, int>();
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var K = read[1];
            int redNum = N - K;
            var rets = new long[K];
            for (int i = 0; i < K; i++)
            {
                var C1 = nCm(redNum + 1, i + 1) % div;
                var C2 = nCm(K - 1, i) % div;
                rets[i] = ((C1 * C2) % div);
                Console.WriteLine(rets[i]);
            }
        }
        public static long nCm(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return (n * (nCm(n - 1, m - 1) % div)) % div * modinv(m, div);
        }

        public static long modinv(long a, long m)
        {
            long b = m, u = 1, v = 0;
            while (b > 0)
            {
                long t = a / b;
                a -= t * b; swap(ref a, ref b);
                u -= t * v; swap(ref u, ref v);
            }
            u %= m;
            if (u < 0) u += m;
            return u;
        }
        public static void swap(ref long a, ref long b)
        {
            var temp = a;
            a = b;
            b = temp;
        }

    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int H, W, h, w;
	cin >> H>>W>>h>>w;


	cout << (H - h)*(W - w) << endl;


	return 0;
}


Measured memory_bytes: 256