akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {

            var n = "Negative";
            var p = "Positive";
            var z = "Zero";
            //Console.SetIn(new StreamReader("input.txt"));

            var ints = In.Ints().ToArray();
            var a = ints[0];
            var b = ints[1];

            if(a==0 || b == 0)
            {
                Out(z);return;
            }

            if (a < 0 && 0 < b)
            {
                Out(z); return;
            }

            if (a < 0 && b < 0)
            {
                if ((b - a) % 2 == 0)
                {
                    Out(n); return;
                }
                else
                {
                    Out(p); return;
                }
            }

            if(a > 0 && b > 0)
            {
                Out(p); return;
            }
            return;
        }

        static void Out(Object o){
            Console.WriteLine(o);
        }
    }




    class In
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static IEnumerable<int> Ints()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i));
        }

        public static String Line()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 3032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N + 1];
		long[] B = new long[N + 1];
		for(int i = 0; i < N; i++) {
			A[i + 1] = sc.nextLong();
			B[i + 1] = sc.nextLong();
		}
		sc.close();
		long cnt = 0;
		for(int i = N; i >= 1; i--) {
			long r = A[i] % B[i];
			if(r != 0) {
				cnt += B[i] - r;
			}
			A[i - 1] += cnt;
		}
		System.out.println(cnt);
	}
}

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

using namespace std;

int main()
{
	int a, b;
    cin>> a>> b;
    int c = max(a, b);
    int d = min(a, b);
    if(c == d)
        cout<<c+d;
    else
        cout<<2*c-1;
 	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
  int w,h,x,y,r;
  int flg;

  flg = 0;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

  if ((y - r) < 0) {
    flg = 1;
  }
  if ((y + r) > h) {
    flg = 1;
  }
  if ((x - r) < 0) {
    flg = 1;
  }
  if ((x + r) > w) {
    flg = 1;
  }

  if (flg == 0) {
    printf("Yes\n");
  }
  else {
    printf("No\n");

  }
  return 0;
}

Measured memory_bytes: 584
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    ans = 0
    t = 0
    pa = a[0]
    for i in a:
        if pa > i:
            if t > 0:
                t = 0
                ans += 1
            else:
                t = -1
        elif pa < i:
            if t < 0:
                t = 0
                ans += 1
            else:
                t = 1
        pa = i
    print(ans+1)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 59116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int Alice = 0,Bob = 0;
  for (int i = 0; i < N; i += 2) {
    Alice += vec.at(i);
  }
  for (int i = 1; i < N; i += 2) {
    Bob += vec.at(i);
  }
  cout << (Alice - Bob) << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ll sum=0;
    int a[n+2];
    map<ll,ll>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        m[a[i]]++;
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int x,y;
        cin>>x>>y;
        sum=sum-m[x]*x+m[x]*y;
        m[y]+=m[x];
        m[x]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 9892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int from,to;
  ll cost;
}edge;
const int V_MAX = 2510,E_MAX = 5010;
int V,E;
ll P;
vector<edge>es(E_MAX);
vector<vector<int> >G(V_MAX);
vector<vector<int> >G2(V_MAX);
vector<bool> canmove(V_MAX,false);
vector<bool> canmove2(V_MAX,false);
vector<ll> d(V_MAX,MAX_I);

//ゴールまで行ける場所
int dfs(int g){
  if(canmove2[g]) return 0;
  canmove2[g] = true;
  for(const int & e : G[g]){
    dfs(e);
  }
  return 0;
}
int dfs2(int g){
  if(!canmove2[g])return 0;
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G2[g]){
    dfs2(e);
  }
  return 0;
}

int bellmanford(int s){
  rep(i,V)d[i] = MAX_I;
  d[s] = 0;
  if(!canmove[s]) return 0;
  while(true){
    bool update = false;
    for(const edge &e : es){
      if(!canmove[e.from])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        update = true;
      }
    }
    if(!update)break;
  }
  return 1;
}

bool find_negative_loop(){
  rep(i,V)d[i] = 0;
  rep(i,V){
    for(const edge &e : es){
      if(!canmove[e.from])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1)return true;
      }
    }
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> P;
  rep(i,E){
    int A,B;
    ll C;cin >> A >> B >> C;
    --A;--B;
    es.push_back({A,B,P-C});
    G[B].push_back(A);
    G2[A].push_back(B);
  }
  dfs(V-1);
  dfs2(0);
  if(find_negative_loop()){
    cout << -1 << endl;
    return 0;
  }
  bellmanford(0);
  cout << max(0ll,-d[V-1]) << endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.math.*;

class Main{
public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   long[] count = new long[200005];
   for(int i=0;i<200005;i++){
     count[i] = 0;
   }
   int[] a = new int[n];
   for(int i=0;i<n;i++) {     
   int t = sc.nextInt();
   a[i] = t;
   count[t] += 1;
            }
   long ret = 0;
   for(int i=0;i<200005;i++){
     ret += count[i]*(count[i]-1);
   }
   ret /= 2;
   for(int i=0;i<n;i++) { 
   int t = a[i];
   long remove = count[t]*(count[t]-1) - (count[t]-1)*(count[t]-2);
   remove /= 2;
   System.out.println(ret-remove);
   }
}
}


Measured memory_bytes: 103512
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int n, x, i, j, k, num;

	while(1){
		//input
		cin >> n >> x;

		//init
		num = 0;
		for(i = 1; i <= n; i++){
			for(j = (i + 1); j <= n; j++){
				for(k = (j + 1); k <= n; k++){
					if((i + j + k) == x){
						//hit
						num++; 
						break;
					}
				}
			}
		}

		//end condition
		if(n == 0 && x == 0){
			break;
		}
		else{
			//output
			cout << num << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int A,B,n,i;
  cin >> A >> B;
  n = A;
  i = 0;
  while ( n <= B )
  {
    int a1,a2,a3,a4,a5;
    a1 = n/10000;
    a2 = n/1000-a1*10;
    a3 = n/100-(n/1000)*10;
    a4 = n/10-(n/100)*10;
    a5 = n%10;
    if ( a1==a5 && a2==a4 )
    { i++;}
    n++;
  }
  cout << i << endl;
}
      

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a==c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }

constexpr int BITS = 30;
int solve(int n, int k, int q, vector<int> const & a) {
    int answer = INT_MAX;
    set<int> ys(ALL(a));
    for (int y : ys) {
        vector<int> c;
        for (int l = 0; l < n; ) {
            int r = l;
            while (r < n and a[r] >= y) ++ r;
            if (r - l >= k) {
                vector<int> b(a.begin() + l, a.begin() + r);
                sort(ALL(b));
                c.insert(c.end(), b.begin(), b.begin() + (r - l - k + 1));
            }
            l = r + 1;
        }
        sort(ALL(c));
        if (q - 1 < c.size()) {
            int x = c[q - 1];
            chmin(answer, x - y);
        }
    }
    return answer;
}

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> a(n);
    REP (i, n) cin >> a[i];
    cout << solve(n, k, q, a) << endl;
    return 0;
}


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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 2e5 + 10;
const int M = (int) 20;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

const int nx[4] = {0, 0, -1, 1};
const int ny[4] = {1, -1, 0, 0};

int n;
pii a[N];
int ans[N];

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].f;
    a[i].s = i;
  }
  sort (a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (i - 1 >= n / 2) {
        ans[a[i].s] = a[n / 2].f;
    } else  {
        ans[a[i].s] = a[n / 2 + 1].f;
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 4480
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[123123];
int pd;

int main()
{
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) {scanf("%d",&a[i]);if(a[i]) pd=1;}
  if(!pd) {printf("Yes");return 0;}
  if(n%3!=0) {printf("No");return 0;}
  sort(a+1,a+1+n);
  for(i=2;i<=n/3;i++) if(a[i]!=a[i-1]) {printf("No");return 0;}
  for(i=n/3+2;i<=n/3*2;i++) if(a[i]!=a[i-1]) {printf("No");return 0;}
  for(i=n/3*2+2;i<=n;i++) if(a[i]!=a[i-1]) {printf("No");return 0;}
  if((a[1]^a[n/3+1])==a[n/3*2+1]) {printf("Yes");return 0;}
  else {printf("No");return 0;}
} 

Measured memory_bytes: 640
import java.util.Scanner;

//C
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		int[] xList = new int[N];
		int[] yList = new int[N];
		int[] hList = new int[N];

		for(int i = 0; i < N; i++) {
			xList[i] = Integer.parseInt(sc.next());
			yList[i] = Integer.parseInt(sc.next());
			hList[i] = Integer.parseInt(sc.next());

		}


		for(int Cx = 0; Cx <= 100; Cx++) {
			for(int Cy = 0; Cy<= 100; Cy++) {
				int Hkoho = 0;
				boolean seikaiFlg = true;

				// hi が0じゃない最初のやつを探す (全部0は特定できるという条件から、ありえない)
				for(int i = 1; i < N; i++){
					if(hList[i] == 0) {
						continue;
					}else {
						Hkoho =  (Math.abs(xList[i] - Cx) + Math.abs(yList[i] - Cy)) + hList[i];
						break;
					}
				}

				for(int i = 0; i < N; i++){
					int aaa = Hkoho - (Math.abs(xList[i] - Cx) + Math.abs(yList[i] - Cy));

					if(aaa < 0) {
						if(hList[i] == 0) {
							continue;
						}else {
							// 次の座標へ
							seikaiFlg = false;
							break;
						}
					}else{
						if(hList[i] == aaa) {
							continue;
						}else {
							// 次の座標へ
							seikaiFlg = false;
							break;
						}
					}
				}
				if(seikaiFlg == true) {
					System.out.println(Cx + " " + Cy + " "+ Hkoho);
				}

			}
		}
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
#include<math.h>

int main()
{
    int a,c,b;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c){
        printf("1\n");
    }
    else if(a==b||b==c||a==c){
        printf("2\n");
    }
    else {
        printf("3\n");
    }



    return 0;
}


Measured memory_bytes: 128
h,w=map(int,input().split())
li=[input() for _ in range(h)]
for i in range(h):
    res=""
    for j in range(w):
        cnt=0
        if li[i][j]==".":
            for x in range(-1,2):
                for y in range(-1,2):
                    if 0<=i+x<h and 0<=j+y<w and li[i+x][j+y]=="#":
                        cnt+=1
            res+=str(cnt)
        else:
            res+="#"
    print(res)

Measured memory_bytes: 9132
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  
  int x, y, xmax=X, ymin=Y;
  for (int i = 0; i < N; ++i) {
    cin >> x;
    xmax = max(xmax, x);
  }

  for (int i = 0; i < M; ++i) {
    cin >> y;
    ymin = min(ymin, y);
  }

  for (int i = X; i <= Y; ++i) {
    if (xmax < i && ymin >= i) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()

  val array = Array(n) { Array(m) { 0 } }

  for (i in 0 until n) {
    val k = sc.nextInt()
    for (j in 0 until k) {
      val a = sc.nextInt() - 1
      array[i][a] = 1
    }
  }

  val ansArray = Array(m) { 0 }
  for (i in 0 until n) {
    val ai = array[i]
    for (j in 0 until m) {
      ansArray[j] += ai[j]
    }
  }
  val ans = ansArray.filter { it == n }.size

  println(ans)
}


Measured memory_bytes: 31384
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    S = input()

    ans = 0
    for x in range(0, 1000):
        t = "{:0=3}".format(x)
        j = 0
        for i in range(N):
            if t[j] == S[i]:
                j += 1
            if j == 3:
                ans += 1
                break

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 74928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s;
int k;
string t[30000];
int main(void){
    cin>>s>>k;
    if(s.size()==1){
        cout<<s<<endl;
        return 0;
    }
    int c=0;
    for(int i=0;i<s.size();i++){
        string S="";
        int m;
        if(s.size()<=i+k){
            m=s.size();
        }else{
            m=i+k;
        }
        for(int j=i;j<m;j++){
            S+=s[j];
            t[c]=S;
            c++;
        }
    }
    sort(t,t+c);
    if(k==1){
        cout<<t[0]<<endl;
        return 0;
    }
    int I=1;
    int J=1;
    while(true){
        if(t[I]!=t[I-1]){
            J++;
            if(J==k){
                cout<<t[I]<<endl;
                return 0;
            }
        }
        I++;
    }

}


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

public class Prog
{
    public void run()
    {
        var input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int X = int.Parse(input[1]);
        input = Console.ReadLine().Split();
        int D = 0;
        int ans = 1;
        int[] L = Array.ConvertAll(input, int.Parse);
        for(int i = 0; i < N; i++)
        {
            D += L[i];
            if(X < D)
            {
                break;
            }
            ans++;
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        //var input = Console.ReadLine().Split();
        //int[] X = Array.ConvertAll(input, int.Parse);
        var prog = new Prog();
        prog.run();
    }
}

//Array.ConvertAll(int.Parse)

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

static int compareFunction(const void *lhs, const void *rhs) {
  // 昇順(char)
  return strcmp(lhs, rhs);
}

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

  char kind[amount][11];
  for (int i = 0; i < amount; i += 1) {
    scanf("%s", *(kind + i));
  }
  // ソートして同じ種類のものを固める
  qsort(kind, amount, sizeof(*kind), compareFunction);

  // 1つ目の種類に関しては絶対カウント1するので1から始める
  // 同じので固まっていても違うものが出てきて初めてインクリメントなのでこれでOK
  // たとえ全部同じでも1が正解だし
  int output = 1;

  // index + 1 との比較になるため、i < amount - 1 が条件
  for (int i = 0; i < amount - 1; i += 1) {
    // 並べ替え後の1つ目2つ目...を比較して違っていたらカウントをインクリメント
    if (strcmp(*(kind + i), *(kind + i + 1)) != 0) {
      output += 1;
    }
  }

  printf("%d", output);
  printf("%c", '\n');

  return 0;
}


Measured memory_bytes: 5744
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int H , W;
int a[222][222];
LL dp[444][222][222];

int main(){
	scanf("%d%d" , &H , &W);
	repp(i,1,H+1){
		repp(j,1,W+1){
			scanf("%d" , &a[i][j]);
		}
	}
	int n = H + W + 1;
	dp[2][1][1] = a[1][1];
	repp(i,3,n){
		int x = max(1,i-W);
		int y = min(i,H+1);
		repp(j,x,y){
			repp(k,x,y){
				dp[i][j][k] = max(max(dp[i-1][j-1][k] , dp[i-1][j][k]) , max(dp[i-1][j-1][k-1] , dp[i-1][j][k-1])) + a[j][i-j] + (j != k ? a[k][i-k] : 0);
			}
		}
	}
	printf("%lld\n" , dp[H+W][H][H]);
	return 0;
}


Measured memory_bytes: 70912
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-03-17
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10) << fixed;
    string str;
    cin >> str;
    set<char>st;
    st.insert(str[0]);
    st.insert(str[1]);
    st.insert(str[2]);
    if((int)st.size() == 1){
		cout << "No\n";
	}else{
		cout << "Yes\n";
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  long int a,b;
  double c,d;
  cin>>a>>b;
  c=a;
  d=b;
  cout<<a/b<<" "<<a%b<<" "<<fixed<<setprecision(5)<<c/d<<endl;
  return 0;
}

Measured memory_bytes: 3288
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	double mul = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mul *= a[i];
	}
	double sum = 0;
	for (int i = 0; i < n; i++) {
		sum += mul / a[i];
	}
	dumpf(mul / sum, 6);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  // 1 4 2 3 5
  // ↓ mod K
  // ↓ -1
  // 0 -1 1 2 0

  // 10 7
  // 14 15 92 65 35 89 79 32 38 46
  //
  // ↓ mod K
  //
  // 0 1 1 2 0 5 2 4 3 4 （和%K = 要素数、という意味は変わらない）
  //
  // ↓ -1 (mod K)
  //
  // 6 0 0 1 6 4 1 3 2 3  (和%K = 0 | ただし要素数 < K)

  // 実際にやってみる
  // 8 4
  // 4 2 4 2 4 2 4 2
  //
  // まず -1 mod K の数列にする
  // 3 1 3 1 3 1 3 1

  // 1つ目の数が0なら数える
  // 2つ目の数では、1つ目にそれを足して、0である数を数える
  // 3つ目の数では、1つ目と2つ目にそれを足し、0を数える
  // ...
  // ただし加算が大変なので、変わりに「0を数える」の「0」をマイナスする
  // ＝判定ラインを下げることで、実質足したみたいにする
  // ...こうすると加算は必要なくなる
  //
  // 3 1 3 1 3 1 3 1
  // 1つ目は3なので、判定ラインは0-3=-3 mod K=1になる。3+1=0(mod K)を追加する。
  // 2つ目は1なので、判定ラインは1-1=0になる。1+0=1を追加する。
  // 1つ目の数が、判定ラインの0と一致するため、リザルトとして1つ数える
  // ...
  //
  // あとは要素数 < K にするために、mapに消費期限を入れていけば良いのではないか

  int N, K;
  cin >> N >> K;
  unordered_map<int, vector<int>> as;
  i64 result = 0;
  int jl = 0; // 判定ライン
  F0R(i, N) {
    int a;
    cin >> a;
    a = (a - 1 + K) % K;
    jl = (jl - a + K) % K;
    a = (a + jl) % K;
    //debug(jl);
    //debug(a);
    as[a].push_back(i);

    int n = lower_bound(rng(as[jl]), i - K + 2) - as[jl].begin();
    result += as[jl].size() - n;
    //debug(result);
  }
  cout << result;
}
#endif


Measured memory_bytes: 17864
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int sm = 0;
    for(int i = 0; i < M; i++) sm += a[i];

    if(sm > N) {
        cout << -1 << endl;
    } else {
        cout << N - sm << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
<?php

$sc = new Scanner();

$S = $sc->next();
$N = strlen($S);

$ans = false;

for($i = 0; $i < $N; $i++) {
    for($j = $i; $j < $N; $j++) {
        $t = substr($S, 0, $i) . substr($S, $j);
        if ($t === 'keyence') {
            $ans = true;
            break;
        }
    }
}
echo $ans ? 'YES' : 'NO' . PHP_EOL;

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


Measured memory_bytes: 4728
require 'matrix'

n, m, l = gets.split.map(&:to_i)
a = Array.new()
b = Array.new()
n.times do |i|
  a << gets.split.map(&:to_i)
end
m.times do
  b << gets.split.map(&:to_i)
end
mc = Matrix.rows( a ) * Matrix.rows( b )
(0...n).each do | i |
  puts mc.row( i ).to_a.join(" ")
end

Measured memory_bytes: 9768
#include<cstdio>
#include<algorithm>
const int N=1000007;
char s[N],t[N];int n,ans,sum[N];
int main()
{
    scanf("%d%s%s",&n,s+1,t+1);
    for(int i=n,f=0,k=0,p=n;i;--i)
    {
    f+=sum[i+k];
    if(p>i||t[i]^s[p])
        {
        for(;p>0&&(p>i||t[i]^s[p]);--p);
        if(p==i) continue;
        if(p<=0) return !printf("-1");
        ++k,++f,sum[i+k-1]=0,--sum[p+k-1];
        }
    ans=std::max(ans,f);
    }
    printf("%d",ans);
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
int c = 0;
vector< vector<int> > v(2500, vector<int>(15,0));
vector<int> buf(15);

void dfs(int i,const int size, const int range_start, const int range_end)
{
    if (i == size) {
        for(int i = 0; i < size; ++i){
            v[c][i] = buf[i];
        }
        c++;
    }
    else{
        for(int j = range_start; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end);
        }
    }
}

int main(){
    int N,M; cin >> N >> M;
    int ans = 0;
    int k[M]; int s[20][M]; int p[M];
    for(int i = 0;i<M;i++){
        cin >>k[i];
        for(int j = 0;j<k[i];j++) {cin >> s[i][j]; s[i][j]--;}
    }
    for(int i = 0;i<M;i++) cin >> p[i]; 


    dfs(0, N, 0, 1);

    for(int i = 0;i<pow(2,N);i++){
        for(int j=0;j<M;j++){
            int div = 0;
            for(int l=0;l<k[j];l++){
                if(v[i][s[j][l]] == 1) div++;
            }
            //cout << div << endl;
            //cout << div%2;
            if (div%2 != p[j])  break;
            if(j == M-1) ans++;
        }
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<double, P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000

int main() {
  int N,M;
  cin>>N>>M;
  int S[N];
  int T[M];
  rep(i,N){cin>>S[i];}
  rep(i,M){cin>>T[i];}
  ll dp[N+1][M+1];
  rep(i,N+1){
    rep(j,M+1){
      dp[i][j]=0ll;
    }
  }
  rep(i,N+1){dp[i][0]=1ll;}
  rep(j,M+1){dp[0][j]=1ll;}
  rep(i,N){
    rep(j,M){
      if(S[i]==T[j]){
        dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1];
        dp[i+1][j+1]%=MOD;
      }
      else{
        dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j];
        dp[i+1][j+1]+=MOD;
        dp[i+1][j+1]%=MOD;
      }
    }
  }
  cout<<dp[N][M];
}

Measured memory_bytes: 34860
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
vector <int> adj[100001];
vector <int> dp(100001,0);
vector <bool> vis(100001,false);
void dfs(int u){
    for(int v:adj[u]){
        if(vis[v]==false){
            vis[v]=true;
            dfs(v);
        }
        dp[u]=max(dp[u],dp[v]+1);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int u,v;
            cin>>u>>v;
            adj[u].push_back(v);
        }
        for(int i=1;i<=n;i++){
            if(vis[i]==false){
                vis[i]=true;
                dfs(i);
            }   
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            //cout<<dp[i]<<" ";
            ans=max(ans,dp[i]);
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 12472
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

if __name__=='__main__':
  S = int(input())
  f = lambda x: int(x/2) if x%2==0 else int(3*x+1)
  li = [S]
  m = 1
  curr = S
  while True:
    curr = f(curr)
    m += 1
    if curr in li:
      break
    li += [curr]
  print(m)

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

long long gcd(long long x, long long y) {
    if  ( y == 0) return x;
    else return gcd(y, x % y);
}

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

    long long sum = 0;

    for (int a = 1; a <= k; ++a){
        for (int b = 1; b <= k; ++b){
            for (int c = 1; c <= k; ++c){
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum << endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

int main()
{
	ll cur[16] = {0};
	ll next[16] = {0};
	string s;
	ll N,K;
	ll i,j,k;
	ll ans = 0;
	ll mod = 1000000007;
	cin >> s;
	ll s_len = s.size();
	int p[13]={0,10,7,4,1,11,8,5,2,12,9,6,3};
	cur[0] = 1;
	for(i=0;i<s_len;++i)
	{

		if(s[i]=='?')
		{
			for(j=0;j<13;++j)
			{
				for(k=0;k<10;++k)
				{
					next[(p[j]+k)%13] += cur[j];
				}
			}
		}
		else
		{
			k = s[i]-'0';
			for(j=0;j<13;++j)
			{
				next[(p[j]+k)%13] += cur[j];
			}
		}
		for(j=0;j<13;++j)
		{
			cur[j] = next[j]%mod;
			next[j] = 0;
		}
	}
	cout << cur[5] << endl;
	return 0;
}




















Measured memory_bytes: 512
import numpy as np
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a.sort()

dp = [0]*(a[-1]+1)
dp = np.array(dp,int)

for i in a:
    dp[i] = 1

for i in a:
    if dp[i] == 1:
        dp[2*i::i] = 0

c = Counter(a)

for i,j in c.items():
    if j > 1:
        dp[i] = 0

print(dp.sum())

Measured memory_bytes: 63208
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e6 + 5, MX = 1e9;
int cnt(int n){
    int ret = 0;
    while (n) {
        n /= 100;
        ++ret;
    }
    return ret;
}
char a[N];
int main(){
    int cnt = 0;
    scanf("%s", a);
    for(int i = 0; a[i]; ++i)
        cnt += a[i] == '+' ? 1 : -1;
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;
int val(int x,int y,int k){
    return(k * (y - 1) - (((y - 2) * (y - 1)) / 2) + x);
}
int main() {
    ll N;
    cin >> N;
    ll k = -1;
    for(int i = 0; i < 1000; i++){
        if(2 * N == i * (i + 1)){
            k = i;
        }
    }
    if(k == -1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << k+1 << endl;
    for(int y = 1; y <= k; y++){
        cout << k << " ";
        for(int x = 1; x <= k; x++){
            if(y + x <= k + 1){
                //cout << x <<"," << y << ",";
                cout << val(x,y,k) << " ";
            }else{
                //cout <<  k - y + 1 <<"," << k - x + 1 << ",";
                cout << val(k - y + 1,k - x + 1,k) << " ";
            }

        }
        cout << endl;
    }
    cout << k << " ";
    for(int i = 1; i < k + 1; i++){
        cout << val(i, k - i + 1, k) << " ";
    }
    cout << endl;


}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int c=0;
	bool f=1;
	string s;
	for (int i = 0; i < n; ++i)
	{
		cin>>s;
		if(s=="A") ++c;
		else --c;
		if(c<0) f=0;
	}
	if(c) f=0;
	cout<<(f?"YES\n":"NO\n");
	return 0;
}


Measured memory_bytes: 3168
import sys
import math
import itertools
def input():
    return sys.stdin.readline()[:-1]

n,m=map(int,input().split())
g = [[]for i in range(n)]
lis = [i for i in range(2,n+1)]

for i in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ans=0
for i in itertools.permutations(lis):
    now = 0
    jud = True
    for j in list(i):
        if j-1 not in g[now]:
            jud = False
            continue
        else:
            now = j-1

    if jud==True:
        ans+=1

print(ans)


Measured memory_bytes: 39920
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int ret=0;
	string s; cin>>s;
	for (char ch : s)
		ret+=ch-'0';
	cout<<(ret%9==0 ? "Yes" : "No")<<"\n";
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int five = 0;
  int seven = 0;
  for (int i = 0; i < 3; i++) {
   int j;
   cin >> j;
   if (j == 5) {five++;}
   if (j == 7) {seven++;}
  }
  if (five == 2 && seven == 1) {cout << "YES";}
  else {cout << "NO";}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
vector<int> g[100010];
bool used[100010];
void dfs(int x){
    used[x]=1;
    for(auto y:g[x]){
        if(!used[y]){
            dfs(y);
        }
    }
}
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int u, v, w; cin>>u>>v>>w;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int c=0;
    for(int i=0; i<n; i++){
        if(!used[i]){
            c++;
            dfs(i);
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 8960
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
using ll = long long;
const ll mod = 1000000007ll;


int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n-m)>1) {
		cout << 0 << endl;
		return 0;
	}
	else {
		ll nn = 1;
		int nc = n;
		int mc = m;
		while(n>0) {
			nn *= n;
			nn %= mod;
			n--;
		}
		ll mm = 1;
		while(m>0) {
			mm *= m;
			mm %= mod;
			m--;
		}
		if (nc==mc) cout << (2*mm*nn)%mod << endl;
		else cout << (mm*nn)%mod << endl;
	}
}

Measured memory_bytes: 256
na=0
nw=0
nt=0
nr=0
i = int(input())
for n in range(i):
    a=input()
    if a=="AC":
        na= na +1
    elif a=="WA":
        nw= nw+1
    elif a=="TLE":
        nt=nt+1
    else:
        nr=nr+1
print('AC x %d'%na)
print('WA x %d'%nw)
print('TLE x %d'%nt)
print('RE x %d'%nr)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int 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) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=998244353;
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;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int a[1000050];
int main()
{
	int n,k; cin>>n>>k;
	if(n&1)
	{
		for(int i=1;i<=k;i++)
		{
			cout<<i<<" "<<n-i<<endl;
		}
	}
	else if(n==2) return 0;
	else
	{
		int cnt=0,i=1;
		while(true)
		{
			cout<<i<<" "<<n/2+1-i<<endl;
			cnt++;
			i++;
			if(i>=n/2+1-i || cnt>=k) break;
		}
		if(cnt>=k) return 0;
		else
		{
			i=n/2+1;
			while(true)
			{
				cout<<i<<" "<<3*(n/2)-i<<endl;
				i++;
				cnt++;
				if(i>=3*(n/2)-i || cnt>=k) break;
			}
		}
	}
	return 0;
}


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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll solve(int N, vi& a, vi& b) {
	vector<pair<int,ii>> ab(N*2);
	rep(i,N) ab[i] = cons(a[i], ii('a',i));
	rep(i,N) ab[N+i] = cons(b[i], ii('b',i));
	sort(ALL(ab));
	ll ans = 0;
	vi usage(N, 0);
	rep(i,N){
		int val = ab[i].first, side = ab[i].second.first, ix = ab[i].second.second;
		ans += val;
		if (side == 'a') usage[ix] |= 1;
		else usage[ix] |= 2;
	}

	vi types(4, 0);
	rep(i,N){
		types[usage[i]]++;
	}
	if (types[1] == N || types[2] == N) return ans;
	assert(types[0] == types[3]);
	if (types[3] > 0) return ans;
	ll best = LLONG_MAX;
	rep(w,N){
		int inN_val = min(a[w], b[w]);
		int next_val = (ab[N].second.second == w) ? ab[N+1].first : ab[N].first;
		best = min(best, ans - inN_val + next_val);
	}
	return best;
}

int main() {
    int N; scanf("%d", &N);
    vi a(N), b(N);
    rep(i,N) {
        scanf("%d%d", &a[i], &b[i]);
    }
    cout << solve(N,a,b) << endl;
    return 0;
}


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

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

int main(void)
{
	string s,ss,p;
	int flg=0;

	cin >> s >> p;

	ss = s + s;
	rep(i, s.length()) {
		flg = 0;
		rep(j,p.length()) {
			if (p.at(j) != ss.at(i + j)) {
				++flg;
				break;
			}
		}
		if (flg == 0) {
			break;
		}
	}
	if(flg==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



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

ans = 0
for i in range(1, N+1):
    count = 0
    if i%2 is 0:
        continue
    for j in range(1, i):
        if (i/j).is_integer():
            count += 1
        if j == i-1 and count == 7:
            ans += 1
print(ans)


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

int main() {
    int N, K, R, S, P;
    string T, M = "";
    cin >> N >> K >> R >> S >> P >> T;
    long long score = 0;
    for(int i=0; i<N; i++)
        M += (T[i] == 'r' ? 'p' : (T[i] == 'p' ? 's' : 'r'));

    for(int i=0; i<N; i++) {
        if(i < K)
            score += (M[i] == 'r' ? R : (M[i] == 'p' ? P : S));
        else {
            int t1 = (M[i] == 'r' ? R : (M[i] == 'p' ? P : S)),
                t2 = (M[i-K] == 'r' ? R : (M[i-K] == 'p' ? P : S));
            
            if(M[i-K] == 'x' || M[i-K] != M[i])
                score += t1;
            else if(t1 > t2) {
                score += t1;
                score -= t2;
            } else 
                M[i] = 'x';
        }    
    }

    cout << score << "\n";
}

Measured memory_bytes: 512