akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
#include <cfloat>
using namespace std;
 
typedef ostringstream OSS;
typedef istringstream ISS;
 
typedef vector<int> VI;
typedef vector< VI > VVI;
 
typedef vector<double> VD;
typedef vector< VD > VVD;
typedef vector< VVD > VVVD;
 
typedef long long LL;
 
typedef pair<int, int> PII;
typedef vector<PII> VPII;
 
#define X first
#define Y second
 
const LL MOD = 1000000007;
const double EPS = 1e-6;
 
struct Edge{
    Edge (int t, int d, int s) : to(t), dist(d), speed(s) {};
    int to, dist, speed;
};
 
typedef tuple<double, int, int, int> State;
 
const double INF = DBL_MAX / 2;
const int SPEED_MAX = 30;
 
int main(void) {
    for (int N, M, S, G; cin >> N >> M, N;) {
        cin >> S >> G;
        S--; G--;
         
        vector< vector<Edge> > edges(N);
        for (int i = 0; i < M; i++) {
            int from, to, dist, speed;
            cin >> from >> to >> dist >> speed;
            from--; to--;
            edges[from].push_back(Edge(to, dist, speed));
            edges[to].push_back(Edge(from, dist, speed));
        }
 
        // current, before, speed
        VVVD times(N, VVD(N, VD(SPEED_MAX+1, INF)));
        times[S][S][0] = 0;
 
        priority_queue<State, vector<State>, greater<State>> q;
        q.emplace(0, S, S, 0);
 
        while (q.size()) {
            State p = q.top();
            double now_time = get<0>(p);
            int current = get<1>(p);
            int before = get<2>(p);
            int speed = get<3>(p);
            q.pop();
 
            if (times[current][before][speed] + EPS < now_time) {
                continue;
            }
 
            for (int di = -1; di <= 1; di++) {
                int next_speed = speed + di;
                if (next_speed < 1 || SPEED_MAX < next_speed) {
                    continue;
                }
 
                for (auto &edge : edges[current]) {
                    if (edge.to == before) { // U turn!!
                        continue;
                    }
 
                    if (edge.speed < next_speed) { // スピード違反!
                        continue;
                    }
 
                    auto &next_time = times[edge.to][current][next_speed];
                    double cost = 1. * edge.dist / next_speed;
 
                    if (next_time > cost + now_time + EPS) {
                        next_time = cost + now_time;
                        q.emplace(next_time, edge.to, current, next_speed);
                    }
                }
            }
        }
 
        double ans = INF;
        for (int i = 0; i < N; i++) {
            ans = min(ans, times[G][i][1]);
        }
 
        if (ans == INF) {
            cout << "unreachable" << endl;
        }else {
            cout << fixed << setprecision(5) << ans << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 2128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    char in[1010];
    
    cin >> in;
    
    for(int i=0;in[i]!='\0';i++){
        in[i]-=3;
        if(in[i]<'A')
            in[i]+='Z'-'@';
    }
    
    printf("%s\n",in);
    
    return 0;
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
 
using namespace std;
 
 
const int N=1e6+5,MOD=1e9;
 
const int dx[]={0,1,-1,0},
          dy[]={1,0,0,-1};
 
typedef long long ll;
 
int n,m,k,a[N],b[N],q,u,x,y,tc,c,ans;
 
char s[N],s2[N];
 
vector<int> v;

int main() {
    scanf("%s",s);
    if (s[0]=='S'){
        printf("Cloudy\n");
    }    
    else if (s[0]=='C')
        printf("Rainy\n");
    else{
        printf("Sunny\n");
    }
}

Measured memory_bytes: 256
N, K = [int(v) for v in input().split()]

links = []
for k in range(K):
    L, R = [int(v) for v in input().split()]
    links.append((L, R))

links = sorted(links, key=lambda x: x[1])

count = [1]
sub = [0, 1]
subtotal = 1

for i in range(1, N):
    v = 0
    for l, r in links:
        r2 = i - l + 1
        l2 = i - r
        if l2 < 0:
            l2 = 0
        if r2 >= 0:
            v += sub[r2] - sub[l2]

    count.append(v % 998244353)
    subtotal = (subtotal + v) % 998244353
    sub.append(subtotal )

print(count[-1])


Measured memory_bytes: 24832
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll n;
ll x;
ll s[100];
ll pw[100];
ll ans = 0;
ll pty(ll a, ll b) {
	if (b == 0)return 0;
	if (a == 0)return 1;
	if (b == 1)return 0;
	if (1 + s[a - 1] >= b)return pty(a - 1, b - 1);
	return pw[a - 1] + 1 + pty(a - 1, min(s[a - 1], b - 2 - s[a - 1]));
}

int main() {
	cin >> n >> x;
	s[0] = 1;
	pw[0] = 1;
	for (int i = 1;i <= 50;i++) {
		s[i] = s[i - 1] * 2 + 3;
		pw[i] = pw[i - 1] * 2 + 1;
	}
	cout << pty(n, x) << endl;
	return 0;
}

Measured memory_bytes: 256
from bisect import *

N = int(input())
A = list(map(int, input().split()))
A.sort()
i = bisect_left(A,A[-1]/2)
if A[i] - A[-1]/2 < A[-1]/2 - A[i-1]:
    a = A[i]
else:
    a = A[i-1]
print(A[-1], a)


Measured memory_bytes: 84988
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

ll n,a[444];
ll cum[444];
ll dp[444][444];

ll rec(ll l,ll r){
  if(dp[l][r]!=-1)return dp[l][r];
  dp[l][r]=cum[r]-cum[l]+a[l];
  ll mi=INF;
  for(int i=l;i<r;i++){
    mi=min(mi,rec(l,i)+rec(i+1,r));
  }
  return dp[l][r]+=mi;
}

int main(){
  cin>>n;
  ll sum;
  fill_n(*dp,444*444,-1);
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    cum[i]=sum;
    dp[i][i]=0;
  }

  cout<<rec(0,n-1)<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define MAX 1001
#define f first
#define s second
typedef pair<int, int> P;

int main(){
  int m;
  while(cin >> m, m){
    vector<P> card(m);
    for(int i = 0 ; i < m ; i++){
      cin >> card[i].f >> card[i].s;
    }
    
    int dp[8][MAX] = {0};
    dp[0][0] = 1;
    for(int i = 0 ; i < m ; i++){
      for(int j = 0 ; j < MAX ; j++){
	for(int k = 0 ; k <= card[i].s ; k++){
	  if(card[i].f*k+j < MAX){
	    dp[i+1][card[i].f*k+j] += dp[i][j];
	  }
	}
      }
    }
    int g, ng;
    cin >> g;
    while(g--){
      cin >> ng; 
      cout << dp[m][ng] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r;cin>>r;
  double ans=2*r*3.141592;
  printf("%.5f\n",ans);
  return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int tmp = (i+1)*1.08;
        if(tmp == n){
            cout << (i+1) << endl;
            return 0;
        }
    }  
    cout << ":(" << endl;
    return 0;  
}

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

int Min(int a, int b){
	if(a >= b){
		return b;
	}
	else{
		return a;
	}
}

int main(){
	int N,K;
	scanf("%d %d",&N,&K);
	int x[N];
	int d[N];
	int sum = 0;
	for(int i=0; i<N; i++){
		scanf("%d",&x[i]);
	}
	for(int i=0; i<N; i++){
		d[i] = Min(abs(x[i]), abs(K - x[i]));
		sum += d[i]*2;
	}
	printf("%d\n",sum);

	return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = inp()
b = inpl()
ans = b[0] + b[-1]
for i in range(n-2):
    ans += min(b[i], b[i+1])
print(ans)

Measured memory_bytes: 40488
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int n;
    ll h;
    cin>>n>>h;
    vector<int> a(n);
    vector<int> b(n);
    int ma=0;
    ll sum=0;
    ll cnt=0;
    int p=0;
    REP(i,n){
        cin>>a[i]>>b[i];
        if(ma<a[i]){
            ma=a[i];
            p=i;
        }
    }
    REP(i,n){
        //if(i==p) continue;
        if(b[i]>ma){
            sum+=b[i];
            cnt++;
        }
    }
    if(sum<h){
        h-=sum;
        cnt+=(h+ma-1)/ma;
    }else{
        sum=0;
        cnt=0;
        sort(ALL(b));
        reverse(ALL(b));
        REP(i,n){
            sum+=b[i];
            cnt++;
            if(sum>=h) break;
        }
    }
    OUT(cnt);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = []
for _ in range(2):
    A.append(list(map(int, input().split())))

candies = A[0][0] + sum(A[1])
max_candies = candies
for i in range(N - 1):
    candies = candies + A[0][i + 1] - A[1][i]
    max_candies = max(max_candies, candies)

print(max_candies)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = n - 1;
        for(int i = 2; i <= (int)Math.sqrt(n) + 1; i++) {
            if(n % i == 0) ans = Math.min(ans, i + n / i - 2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
fun main(args: Array<String>) {
    tenka12019beginnera()
}

fun tenka12019beginnera() {
    val (a, b, c) = readLine()!!.split(' ').map { it.toInt() }

    val answer = if (c in a..b || c in b..a) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 38240
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));

			String[] strs = (String[]) br.readLine().split(" ");
			int num1 = Integer.parseInt(strs[0]);
			int num2 = Integer.parseInt(strs[1]);
			int num3 = Integer.parseInt(strs[2]);

			if (num1 < num2 && num2< num3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 17084
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
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 vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

typedef vector<vvi> vvvi ;
const int INV=INT_MAX;

const int LEFT=0,RIGHT=1;
int column(int n){
	switch(n){
	case 1:
	case 4:
	case 7:
		return 0;
	case 2:
	case 8:
		return 1;
	case 3:
	case 6:
	case 9:
		return 2;
	default:
		assert(0);
	}
}
bool ng(int pos,int foot,int next){
	if(foot==LEFT){
		return column(pos)>column(next);
	}else{
		return column(pos)<column(next);
	}
}

int main(){
	string s;
	while(cin>>s,s!="#"){
		int n=s.size();
		vvi dp(n,vi(2,INV));
		REP(j,2){
			dp[0][j]=0;
		}
		REP(i,n-1){
			REP(k,2){
				int next=s[i+1]-'0';
				int j=s[i]-'0';
				if(ng(j,k,next)){
					dp[i+1][k]=min(dp[i+1][k],dp[i][k]+1);
				}else{
					dp[i+1][(k+1)%2]=min(dp[i+1][(k+1)%2],dp[i][k]);
					dp[i+1][k]=min(dp[i+1][k],dp[i][k]+1);
				}
			}
		}
		int ans=INT_MAX;
		REP(i,2){
			ans=min(ans,dp[n-1][i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 6728
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  int alfa[n][26]={};
  for(int i=0;i<n;i++){
    string str;cin>>str;
    for(int j=0;j<str.size();j++){
      alfa[i][str[j]-'a']++;
    }
  }
  string ans="";
  for(int i=0;i<26;i++){
    int mi=INF;
    for(int j=0;j<n;j++){
      mi=min(alfa[j][i],mi);
    }
    for(int j=0;j<mi;j++){
      char c=i+'a';
      ans+=c;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = 1000;
vector<int> to[(int)pow(N_MAX,2)];
int dp[(int)pow(N_MAX,2)]={};
int ok[(int)pow(N_MAX,2)]={};

int dfs(int pos) {
  if (dp[pos]!=-1) return dp[pos];
  ok[pos] = true;
  int result = 0;
  for (auto x: to[pos]) {
    if (ok[x]&&dp[x]==-1) {
      return INF;
    }
    else result = max(result, dfs(x)+1);
    // cout << pos/N_MAX << " " << pos%N_MAX << " " << result << endl;
  }
  return dp[pos] = result;
}

int main() {
  int N; cin >> N;
  int A[N][N-1]; rep(i,N) rep(j,N-1) { cin >> A[i][j]; A[i][j]--; }
  rep(i,N) rep(j,N-2) { 
    int ti1 = min(i,A[i][j]), tj1 = max(i,A[i][j]);
    int ti2 = min(i,A[i][j+1]), tj2 = max(i,A[i][j+1]);
    to[ti1*N_MAX+tj1].push_back(ti2*N_MAX+tj2);
  }

  fill_n(dp, pow(N_MAX,2), -1);
  int result = 0;
  rep(i,N) rep(j,N) result = max(result, dfs(i*N_MAX+j));
  result = (result<INF) ? result+1 : -1;
  cout << result << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int n;
  cin >> n;
  vector < int > a (n);
  ll sum = 0, mx = ((ll)n * (n + 1)) / 2;
  for (auto &i : a) cin >> i, sum += i;

  if (sum % mx != 0) {
    cout << "NO\n";
    return 0;
  }

  ll k = sum / mx;

  for (int i = 1; i < n; i++) {
    int d = a[i] - a[i - 1];
    ll val = k - d;
    if (val < 0 || val % n != 0) {
      cout << "NO\n";
      return 0;
    }
  }

  cout << "YES\n";
}


Measured memory_bytes: 3708
N,M = (int(i) for i in input().split())

A = []*N
for i in range(N):
    a = input()
    tmp = []
    for j in range(N):
        tmp.append(a[j])
    A.append(tmp)

B = []*M
for i in range(M):
    b = input()
    tmp = []
    for j in range(M):
        tmp.append(b[j])
    B.append(tmp)
    

same = False
for i in range(N-M+1):
    for l in range(N-M+1):
        count = 0
        for j in range(M):
            for k in range(M):
                if B[j][k] == A[j+i][k+l]:
                    count += 1
        if count == M*M:
            same = True
            break



if same:
    print("Yes")
else:
    print("No")

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

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main(){
  int t;cin>>t;
  while(t--){
    int n,m,a,b;cin>>n>>m>>a>>b;
    cout<<floor_sum(n,m,a,b)<<endl;
  }
}


Measured memory_bytes: 3640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


int main_C() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);

    ll L, R; cin >> L >> R;

    ll ans = LINF;
    for (ll i = L; i < min(R, L+2020LL); i++) {
        ll l = i % 2019;
        for (ll j = i + 1; j <= min(R, L+2020LL); j++) {
            ll r = j % 2019;
            ans = min(ans, (l*r) % 2019);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n; cin >>n;
  int num=1;
  while (true){
    if (num * (num+1) / 2 >= n) break;
    num++;
  }
  // 最大値はnumになる
  int sub = num * (num+1) / 2 - n; //1からnumまで足したらどれだけ超過してるか
  cout <<num <<endl;
  for (int i=num-1; i>=1; i--){
    if (sub >= i){
      sub -= i; continue;
    }
    cout <<i <<endl;
  }
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut ans:usize = 0;
    for i in 1..n+1 {
        if i%3 != 0 && i%5 != 0 {
            ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
	
int main() {
	string b; cin >> b;
	int a = b[b.size()-1];

	
	if(a==51){
		cout << "bon";
	} else if (a==48 ||a== 49||a== 54 ||a== 56){
		cout << "pon";
	} else {
		cout << "hon";
	}
}

Measured memory_bytes: 3592
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll odd_cnt = 0;
  ll n;
  cin >> n;
  REP(i,n){
    ll a;
    cin >> a;
    if(a%2==1) odd_cnt++;
  }
  if(odd_cnt%2==1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t, a, n = 0 , 1, len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int alice, bob;
    int total = 0;
    while (a.size() > 0){
        alice = a.at(0);
        a.erase(a.begin());
        if (a.size() == 0){
            total += alice;
            break;
        }
        bob = a.at(0);
        a.erase(a.begin());
        total += alice - bob;
    } 
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();
  for line in stdin.lock().lines().filter_map(|x| x.ok()) {
    let mut iter = line.trim().split_whitespace()
      .map(|x| x.parse::<i32>().unwrap());

    let n = iter.next().unwrap();
    let x = iter.next().unwrap();

    if n == 0 && x == 0 {
      break;
    }

    let mut cnt = 0;

    for i in 1..n-1 {
      for j in i+1..n {
        for k in j+1..n+1 {
          if i + j + k == x {
            cnt += 1;
          }
        }
      }
    }

    println!("{}", cnt);
  }
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m, k;
    cin >> m >> k;
    if (k >= (1 << m)) {
        cout << -1 << endl;
        return 0;
    }
    if (k == 0) {
        for (int i = 0; i < 1 << m; i++) {
            cout << i << ' ' << i << ' ';
        }
        return 0;
    }

    if (m <= 2) {
        vector<int> as;
        for (int i = 0; i < 1 << m; i++) as.push_back(i);
        for (int i = 0; i < 1 << m; i++) as.push_back(i);

        sort(as.begin(), as.end());

        do {
            vector<vector<int>> pos(1 << m);
            for (int i = 0; i < 1 << (m + 1); i++) {
                pos[as[i]].push_back(i);
            }
            bool ok = true;
            int x = -1;
            for (int i = 0; i < 1 << m; i++) {
                int y = 0;
                for (int j = pos[i][0]; j <= pos[i][1]; j++) {
                    y ^= as[j];
                }
                if (x == -1) x = y;
                else {
                    if (x != y) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok && x == k) {
                for (int a : as) {
                    cout << a << ' ';
                }
                return 0;
            }
        } while (next_permutation(as.begin(), as.end()));
    }
    if (m == 1 && k == 1) {
        cout << -1 << endl;
        return 0;
    }

    set<int> used;
    int x = k == 1 ? 2 : 1;
    used.insert(k);
    used.insert(x);
    used.insert(k ^ x);
    vector<int> hoge;
    for (int i = 0; i < 1 << m; i++) {
        if (used.count(i) == 0) hoge.push_back(i);
    }

    assert(hoge.size() >= 2);
    vector<int> ans;
    ans.push_back(x);
    vector<int> tmp;
    for (int i = 0; i < 1; i++) {
        tmp.push_back(hoge[i]);
    }
    for (int a : tmp) {
        ans.push_back(a);
    }
    ans.push_back(k);
    reverse(tmp.begin(), tmp.end());
    for (int a : tmp) {
        ans.push_back(a);
    }
    ans.push_back(x);
    ans.push_back(x ^ k);
    tmp.clear();
    for (int i = 1; i < hoge.size(); i++) {
        tmp.push_back(hoge[i]);
    }
    for (int a : tmp) {
        ans.push_back(a);
    }
    ans.push_back(k);
    reverse(tmp.begin(), tmp.end());
    for (int a : tmp) {
        ans.push_back(a);
    }
    ans.push_back(x ^ k);
    assert(ans.size() == (1 << (m + 1)));
    for (int a : ans) {
        cout << a << ' ';
    }
}


Measured memory_bytes: 3956
#include<stdio.h>

#define int_min -9223372036854775807

int main(void)
{
  long int a, b, c, d;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);

  long int x=int_min;
  long int y=int_min;
  long int z=int_min;
  long int p=int_min;
  if((0<=b) && (0<=d)) x = b * d;
  if((0>=a) && (0>=c)) y = a * c;
  if((0>=b) && (0<=c)) z = b * c;
  if((0>=d) && (0<=a)) p = a * d;

  long int ans;
  ans = x;
  if(ans<y) ans = y;
  if(ans<z) ans = z;
  if(ans<p) ans = p;

  printf("%ld\n", ans);

  return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        static void Solve()
        {
            var nw = ReadAndParseIntArr();
            int n = nw[0];
            int w = nw[1];
            var ws = new int[n];
            var vs = new int[n];
            for(int i=0;i<n;++i)
            {
                var wv = ReadAndParseIntArr();
                ws[i] = wv[0];
                vs[i] = wv[1];
            }
            long[,] dp = new long[n + 1, w + 1];
            for(int i=1;i<=n;++i)
            {
                for(int j=0;j<=w;++j)
                {
                    int idx = i - 1;
                    if (j - ws[idx] >= 0)
                    {
                        dp[i, j] = Math.Max(dp[i - 1, j - ws[idx]] + vs[idx], dp[i - 1, j]);
                    }
                    else
                    {
                        dp[i, j] = dp[i - 1, j];
                    }
                }
            }
            long ans = 0;
            for(int i=0;i<=w;++i)
            {
                ans = Math.Max(ans, dp[n, i]);
            }
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 89056
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

char T[100005] = {0};
char t[100005] = {0};

int main()
{
	int N = 0, K = 0;
	int R = 0, S = 0, P = 0;
	int i = 0, len = 0;
	scanf("%d %d", &N, &K);
	scanf("%d %d %d", &R, &S, &P);
	scanf("%s", T);
	len = strlen(T);

	for (i = 0; i < len; i++) {
		switch(T[i]) {
		case 'r': t[i] = 'p'; break;
		case 's': t[i] = 'r'; break;
		case 'p': t[i] = 's'; break;
		}

		if (i >= K) {
			//printf("x i=%d %c ", i, t[i]);
			if (t[i] == t[i-K]) {
				switch(t[i]) {
				case 'p': t[i] = 'r'; break;
				case 'r': t[i] = 's'; break;
				case 's': t[i] = 'p'; break;
				}
				//printf("xx i=%d %c ", i, t[i]);
				if ((i+K) < len) {
					switch(t[i]) {
					case 'r':
						if (T[i+K] == 's') {
							t[i] = 's';
						}
						break;
					case 's':
						if (T[i+K] == 'p') {
							t[i] = 'p';
						}
						break;
					case 'p':
						if (T[i+K] == 'r') {
							t[i] = 'r';
						}
						break;
					}
					//printf("xxx i=%d %c ", i, t[i]);
				}
			}
		}
		//printf("%c\n", t[i]);
	}
	int g = 0, c = 0, p = 0;
	for (i = 0; i < len; i++) {
		//printf("%c", t[i]);
		switch(t[i]) {
		case 'r':
			if (T[i] == 's') {
				g++;
			}
			break;
		case 's':
			if (T[i] == 'p') {
				c++;
			}
			break;
		case 'p':
			if (T[i] == 'r') {
				p++;
			}
			break;
		}
	}
	printf("%d\n", (g*R) + (c*S) + (p*P));
    return 0;
}


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

int N;
pair<string, pair<int, int>> p[100];

int main(){
  cin >> N;
  for(int i = 0; i < N; ++i){
    cin >> p[i].first >> p[i].second.first;
    p[i].second.first = -p[i].second.first;
    p[i].second.second = i + 1;
  }
  sort(p, p + N);
  for(int i = 0; i < N; ++i){
      cout << p[i].second.second << endl;
  }
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
     
    int h, w;
    int i, j;
     
    while(1) {
        scanf("%d %d", &h, &w);
        if(h==0 && w==0)
            break;
     
        for (i=1; i<=h; i++) {
            for(j=1; j<=w; j++) {
                if(i>1 && i<h && j<w && j>1) printf(".");
                else printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2020
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1.0e-10;

int main()
{
	int h, w;
	cin >> h >> w;

	vector<string> s(h+2, string(w+2, '.'));
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			cin >> s[i][j];
		}
	}

	vector<pair<double, bool> > corner;
	for(int y=1; y<=h; ++y){
		for(int x=1; x<=w; ++x){
			if(s[y][x-1] != s[y][x] && s[y-1][x] != s[y][x]){
				double tmp = atan2(h-y+1.0, x-1.0);
				corner.push_back(make_pair(tmp, false));
			}
			if(s[y][x+1] != s[y][x] && s[y+1][x] != s[y][x]){
				double tmp = atan2(h-y, (double)x);
				corner.push_back(make_pair(tmp, true));
			}
		}
	}
	sort(corner.begin(), corner.end());

	int m = corner.size();
	int num = 1;
	int ret = 1;
	for(int i=0; i<m; ++i){
		if(corner[i].second)
			++ num;
		else
			-- num;
		if(i < m-1 && corner[i+1].first - corner[i].first < EPS)
			continue;
		ret = max(ret, num);
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2804
#include<iostream>
#include<algorithm>
using namespace std;
int x[110];
int main(){
  int a,k;
  cin>>a;
  int b=a*2;
  for(int i=0;i<b;i++){
    cin>>x[i];
    sort(x,x+b);
    reverse(x,x+b);
  }
  for(int i=0;i<a+1;i++){
    k+=x[1+i*2];
  }
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	string s;
	cin >> s;
	deque<char>c;
	for(int i=0;i<s.length();i++)
	{
		c.push_back(s[i]);
	}
	bool flag = true;
	string s1 = "maerd",s2 = "remaerd",s3 = "esare",s4 = "resare";
	while(!c.empty())
	{
		string loc;
		while(!c.empty()&&loc.length()!=5)
		{
			loc = loc+c.back();
			c.pop_back();
		}
		if(loc==s1||loc==s3)
		{
			continue;
		}
		else
		{
			while(!c.empty()&&loc.length()!=6)
			{
				loc = loc+c.back();
				c.pop_back();
			}
			if(loc==s4)
			{
				continue;
			}
			else
			{
				while(!c.empty()&&loc.length()!=7)
				{
					loc = loc+c.back();
					c.pop_back();
				}
				if(loc==s2)
				{
					continue;
				}
				else
				{
					flag = false;
					break;
				}
			}
		}
	}
	if(flag)
	{
		cout << "YES\n";
	}
	else
	{
		cout << "NO\n";
	}
	return 0;
}
	


Measured memory_bytes: 3852
#include<bits/stdc++.h>
#define mo 1000000007
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){ 
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,m,i,j,k,a[20],f[20][(1<<16)+5],jc[(1<<16)+5],ny[(1<<16)+5],ans;
long long book[(1<<16)+5];
bool cmp(long long u,long long v){
	return u>v;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long C(long long u,long long v){
	if(u<v) return 0;
	return jc[u]*ny[v]%mo*ny[u-v]%mo;
}
int main(){
	//freopen("building.in","r",stdin);
	//freopen("building.out","w",stdout);
	n=read();m=read();
	for(i=1;i<=m;i++)
		a[i]=read();
	jc[0]=1;
	ny[0]=1;
	for(i=1;i<=(1<<n);i++){
		jc[i]=jc[i-1]*i%mo;
		ny[i]=ksm(jc[i],mo-2);
	}
	for(i=1;i<(1<<n);i++)
		for(j=1;j<=n;j++)
			if(i&(1<<j-1))
				book[i]=book[i^(1<<j-1)]+1;
	sort(a+1,a+m+1,cmp);
	f[0][0]=1;
	for(i=1;i<=m;i++)
		for(j=0;j<(1<<n);j++){
			f[i][j]=f[i-1][j];
			for(k=0;k<n;k++)
				if(j&(1<<k))
					f[i][j]=(f[i][j]+f[i-1][j^(1<<k)]*C((1<<n)-(j^(1<<k))-a[i],(1<<k)-1)%mo*jc[1<<k])%mo;
		}
	for(j=0;j<(1<<n);j++){
		if(book[j]&1)
			ans=(ans-f[m][j]*jc[(1<<n)-1-j])%mo;
		else
			ans=(ans+f[m][j]*jc[(1<<n)-1-j])%mo;
	}
	ans=(ans+mo)%mo;
	ans=ans*(1<<n)%mo;
	pus(ans,2);
	return 0;
}

Measured memory_bytes: 9984
/*input
9 40 50
5 3 4 7 6 1 2 9 8
*/

#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <utility>
#include <tuple>
#include <climits>
#include <fstream>
#include <bitset>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <random>
#include <chrono>
#include <ios>
#include <iomanip>
#include <functional>
#include <array>

using namespace std;

#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORA(i, a) for (auto &i : a)
#define FORB(i, a, b) for (int i = a; i >= b; --i)
#define SZ(a) ((int) a.size())
#define ALL(a) begin(a), end(a)

typedef int64_t ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fi first
#define se second

// start of code

const int MAXN = 5007;
const ll INF = 1e17;
ll cost[MAXN][MAXN], dp[MAXN], A, B;
int arr[MAXN], N;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> A >> B;
	FOR(i, 1, N) cin >> arr[i];

	arr[N + 1] = N + 1;
	FOR(i, 0, N) {
		ll cur = 0;
		FOR(j, i + 1, N + 1) {
			cost[i][j] = cur;
			cur += (arr[i] < arr[j] ? A : B);
		}
	}

	FOR(i, 1, N + 1) {
		dp[i] = INF;
		FOR(j, 0, i - 1) if (arr[j] < arr[i]) {
			dp[i] = min(dp[i], dp[j] + cost[j][i]);
		}
	}

	cout << dp[N + 1] << endl;

	return 0;
}


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

int main(){
    int64_t N,ans,M;
    long double nextnum = 1000000000000000001;
    bool conti = true;
    ans = 1;
    cin >> N;
    //vector<int64_t> A(N,0);
    for(int64_t i = 0; i < N; i++){
        //cin >> A.at(i);
        cin >> M;
        if(M == 0){
            cout << 0 << endl;
            return 0;
        }
        if(conti == true){
            if(M > nextnum){
                conti = false;
            }
            ans *= M;
            nextnum = 1000000000000000001/M;
        }
        if(ans >= 1000000000000000001){
            conti = false;
        }
    }
    // for(int64_t i = 0; i < N; i++){
    //     // if(A.at(i) >= 1000000000000000001){
    //     //     cout << -1 << endl;
    //     //     return 0;
    //     // }
    //     ans *= A.at(i);
    //     if(ans >= 1000000000000000001){
    //         cout << -1 << endl;
    //         return 0;
    //     }
    // }
    if(conti == true && ans < 1000000000000000001){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3636
import networkx as nx
N, M = map(int, input().split())

G = nx.Graph()

G.add_edges_from(tuple(map(int, input().split())) for _ in range(M))

dist = nx.shortest_path_length(G, target=1)
print('Yes')
for i in range(2, N+1):
  print(min((dist[j], j) for j in nx.all_neighbors(G, i))[1])
    





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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> map(H);
  int count;
  for (int i=0; i < H; i++) {
      cin >> map.at(i);
  }
  for (int i=0; i < H; i++) {
    for (int j=0; j < W; j++) {
      if (map.at(i).at(j) == '#') {
        cout << '#';
        if (j == W - 1) {
          cout << endl;
        }
        continue;
      }
      count = 0;
      if (i - 1 >= 0 && j - 1 >= 0 && map.at(i-1).at(j-1) == '#') {
        count++;
      }
      if (i - 1 >= 0 && map.at(i-1).at(j) == '#') {
        count++;
      }
      if (i - 1 >= 0 && j + 1 < W && map.at(i-1).at(j+1) == '#') {
        count++;
      }
      if (j - 1 >= 0 && map.at(i).at(j-1) == '#') {
        count++;
      }
      if (j + 1 < W && map.at(i).at(j+1) == '#') {
        count++;
      }
      if (i + 1 < H && j - 1 >= 0 && map.at(i+1).at(j-1) == '#') {
        count++;
      }
      if (i + 1 < H && map.at(i+1).at(j) == '#') {
        count++;
      }
      if (i + 1 < H && j + 1 < W && map.at(i+1).at(j+1) == '#') {
        count++;
      }
      cout << count;
      if (j == W - 1) {
        cout << endl;
      }
    }
  }
}

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

int64_t gcd(int64_t p,int64_t q){
	if(p%q==0)return q;
	return gcd(q,p%q);
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans; cin>>ans;
	for(int i=1;i<n;++i){
		int a; cin>>a;
		ans=gcd(ans,a);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n;
    cin >> n;
    vi a(n);
    int sign = 0;
    rep(i,n) {
        int tmp; cin >> tmp;
        if(tmp < 0) sign++;
        a[i] = abs(tmp);
    }

    Sort(a);
    ll ans = 0;
    if(sign%2 == 0){
        rep(i,n) ans += a[i];
    }else{
        rep(i,n-1) ans += a[i+1];
        ans -= a[0];
    }

    cout << ans << endl;


}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;

int main(){
    long long int N, K;
    cin >> N >> K;
    long long int A[1000];
    long long int S = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        S += A[i];
    }
    vector<long long int> v;
    for(int i = 1; i * i <= S; i++){
        if(S % i == 0){
            v.push_back(i);
            v.push_back(S / i);
        }
    }
    long long int ans = 0;
    for(long long int num : v){
        S = 0;
        vector<long long int> rems;
        for(int i = 0; i < N; i++){
            S += A[i] % num;
            rems.push_back(A[i] % num);
        }
        sort(rems.begin(), rems.end());
        int cnt = S / num;
        long long int cost = 0;
        for(int i = 0; i < N - cnt; i++){
            cost += rems[i];
        }
        if(cost <= K){
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
    return 0;
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

//        int n=sc.nextInt();
        int d[][]= new int[4][4];
        for (int i = 0; i < 3; i++) {
    		int a=sc.nextInt()-1;
    		int b=sc.nextInt()-1;
    		d[a][b]=d[b][a]=1;
    	}
        String ans = "NO";
        
loop:
        for (int i = 0; i < 4; i++) {
        	int e[]=new int[4];
			for (int j = 0; j < 4; j++) {
				for (int w = 0; w < 4; w++) {
					for (int v = 0; v < 4; v++) {
						if(func(i,j,w,v) && d[i][j]>0 && d[w][j]>0 && d[w][v]>0 )
						{
							ans="YES";break loop;
						}
					}
				}
			}
		}

        out.println(ans);
        out.flush();
    }

    static boolean func(int a,int b,int c,int e) {
    	int d[]=new int[4];
    	d[a]++;
    	d[b]++;
    	d[c]++;
    	d[e]++;
    	sort(d);
    	if(d[0]==1 && d[3]==1)return true;
    	return false;
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//        this.a=a;
//        this.b=b;
//    }
//    public int compareTo(P p){
//        return b-p.b; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

void fill(string &ans,string &s,int k);
bool check(string &ans,string &s,int k);

int main(){
	int n,i,j,k;
	cin>>n;
	string s;
	cin>>s;
	bool flag=false;
	string ans;
	loop(i,0,2){
		loop(j,0,2){
			ans.clear();
			if(i==0){
				ans+='S';
			}else{
				ans+='W';
			}
			if(j==0){
				ans+='S';
			}else{
				ans+='W';
			}
			loop(k,2,n){
				fill(ans,s,k);
			}
			flag=check(ans,s,n-1);
			if(flag){
				flag=check(ans,s,n);
			}
			if(flag){
				break;
			}
		}
		if(flag){
			break;
		}
	}
	if(!flag){
		cout<<-1<<endl;
	}else{
		loop(i,0,n){
			cout<<ans[i];
		}
		cout<<endl;
	}
}

void fill(string &ans,string &s,int k){
	if(s[k-1]=='o'){
		if(ans[k-1]=='S'){
			if(ans[k-2]=='S'){
				ans+='S';
			}else{
				ans+='W';
			}
		}else{
			if(ans[k-2]=='S'){
				ans+='W';
			}else{
				ans+='S';
			}
		}
	}else{
		if(ans[k-1]=='S'){
			if(ans[k-2]=='S'){
				ans+='W';
			}else{
				ans+='S';
			}
		}else{
			if(ans[k-2]=='S'){
				ans+='S';
			}else{
				ans+='W';
			}
		}
	}
}

bool check(string &ans,string &s,int k){
	int n=ans.size();
	if(s[k%n]=='o'){
		if(ans[k%n]=='S'){
			if(ans[(k-1)%n]==ans[(k+1)%n]){
				return true;
			}else{
				return false;
			}
		}else{
			if(ans[(k-1)%n]==ans[(k+1)%n]){
				return false;
			}else{
				return true;
			}
		}
	}else{
		if(ans[k%n]=='S'){
			if(ans[(k-1)%n]==ans[(k+1)%n]){
				return false;
			}else{
				return true;
			}
		}else{
			if(ans[(k-1)%n]==ans[(k+1)%n]){
				return true;
			}else{
				return false;
			}
		}
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
using namespace std;
const int inf=1e9,mod=1e9+7;
int n,m,S,T,sl,fh,vis[mxn][3];
int t,h[mxn];
struct edge
{
	int to,nxt;
}e[mxn];
queue<pii> q;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void add(int u,int v) {e[++t]=(edge){v,h[u]};h[u]=t;}
int main()
{
	n=rd();m=rd();int x,y;
	for(int i=1;i<=m;++i) x=rd(),y=rd(),add(x,y);
	S=rd();T=rd();
	q.push(mp(S,0));int u;pii nw,nxt;
	while(!q.empty())
	{
		nw=q.front();q.pop();u=nw.fr;
		for(int i=h[u];i;i=e[i].nxt)
		{
			nxt.fr=e[i].to;nxt.sc=nw.sc+1;
			if(vis[nxt.fr][nxt.sc%3]) continue;vis[nxt.fr][nxt.sc%3]=1;
			if(nxt.fr==T&&nxt.sc%3==0) {printf("%d\n",nxt.sc/3); return 0;}
			q.push(nxt);
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 9216
#include <iostream> 

using namespace std;

int main() {

	int H, A;

	cin >> H >> A;
    int attacks = 0;
     bool done = false;
	 while(!done) {
     
      if(H <= 0) {
      	done = true;
      	break;
      }
       attacks += 1;
      H = H - A;

 }
	cout << attacks << "\n";
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int ceil(int a, int b) { return (a + b - 1) / b; }
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int h, a;
    cin>>h>>a;

    cout << ceil(h, a) << endl;
}


Measured memory_bytes: 256
/**
 *  @judge AtCoder
 *  @id abc163_b
 *  @name Homework
 *  @contest AtCoder Beginner Contest 163
 * 
 *  @tag Ad-hoc, Math
 */
#include <bits/stdc++.h>
using namespace std;

typedef long long int LL;

int n, m;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t;
	while (cin >> n >> m) {
		for (int i = 0; i < m; i++) {
			cin >> t;
			n -= t;
		}
		cout << max(-1, n) << endl;
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll k,n;
    cin>>k>>n;
    ll a[n+1];
    rep(0,i,n){
        cin>>a[i];
    }
    a[n]=k+a[0];
    ll maxa=0;
    rep(0,i,n){
        maxa=max(maxa,a[i+1]-a[i]);
    }
    cout<<k-maxa<<endl;
}


Measured memory_bytes: 1792