akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W_CAP; cin >> N >> W_CAP;
    vector<ll> W(N), V(N);
    rep(i, N) cin >> W[i] >> V[i];
    
    map<ll, vector<ll>> group_by_w;
    rep(i, N) group_by_w[W[i]].push_back(V[i]);

    for(auto &p : group_by_w) {
        sort(all(p.second), greater<ll>());
        p.second.insert(begin(p.second), 0);
        rep(i, p.second.size() - 1) p.second[i + 1] += p.second[i];
    }
    
    function<ll(decltype(group_by_w)::iterator, ll)> dfs = [&] (decltype(group_by_w)::iterator itr, ll left) {
        if(itr == end(group_by_w)) return 0LL;
        ll res = 0;
        rep(i, (*itr).second.size()) {
            auto itr2 = itr; itr2++;
            ll add_w = (*itr).first * i;
            if(left - add_w >= 0) {
                set_max(res, (*itr).second[i] + dfs(itr2, left - add_w));
            }
        }
        return res;
    };
    cout << dfs(begin(group_by_w), W_CAP) << endl;
    
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$n);
$str=array("AC","WA","TLE","RE");
for($i=0;$i<$n;$i++){
    fscanf(STDIN,"%s",$s[$i]);
}
$arr=array_count_values($s);
for($j=0;$j<4;$j++){
    if(in_array($str[$j],$s)){
        echo "{$str[$j]} x {$arr["{$str[$j]}"]}\n";
    }else{
        echo "{$str[$j]} x 0\n";
    }
}

Measured memory_bytes: 25352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    rep(i, n) {
        if (n < i * 7)
            continue;
        if ((n - (i * 7)) % 4 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int k; 
    string s;
    cin >> k >> s;
    if(s.size() <= k)
        cout << s << "\n";
    else
        cout << s.substr(0, k) << "...\n";
    return 0;
}


Measured memory_bytes: 3628
n,m,l=gets.split.map(&:to_i)

a = n.times.map{gets.split.map(&:to_i)}
b = m.times.map{gets.split.map(&:to_i)}

c = n.times.map{|i|
  l.times.map{|j|
    m.times.reduce(0){|r,k| r + a[i][k] * b[k][j] }
  }
}

puts c.map{|l|l.join(' ')}.join("\n")



Measured memory_bytes: 9660
#include<cstdio>
#include<map>
using namespace std;
int tot;
map<char,bool>f;
int main()
{
	char c;
	for(int i=1;i<=3;i++) {
		scanf("%c",&c);
		if(!f[c]) tot++;
		f[c]=1;
	}
	if(tot==3)
		printf("Yes\n");
	else
		printf("No\n");
}

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

public class Main {
	private static final int READ_COUNT = 2;
	private static List<String> strList = new ArrayList<>();
	
	public static void main(String[] args) {
		read();
		
		int n = Integer.parseInt(strList.get(0));
		String[] as = strList.get(1).split(" ");
		
		int min = Integer.parseInt(as[0]);
		int max = min;
		
		for (int i = 1; i < n; i++) {
			int num = Integer.parseInt(as[i]);
			min = Math.min(min, num);
			max = Math.max(max, num);
		}
		
		System.out.println(max - min);
	}
	
	private static void read() {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			for (int i = 0; i < READ_COUNT; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
	}
}


Measured memory_bytes: 21076
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.util.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    
		
	  int 	getint(BufferedReader sc) throws java.lang.Exception
		{
	//	  String ss=sc.readLine();
	    	int a= Integer.parseInt(sc.readLine());
	    	return a;
		}
	  ArrayList<Integer> getlistint(BufferedReader sc) throws java.lang.Exception
	  {
		  ArrayList<Integer> res=new ArrayList<>();
		  
		  String s=sc.readLine();
		  String[] ss=s.split(" ");
		
		  for(int i=0;i<ss.length;i++)
		  {
			//  String ss=sc.readLine();
		    	int a=Integer.valueOf(ss[i]);
		    	res.add(a);
		  }
	  
		  return res;
	  }
	  ArrayList<Float> getlistfl(BufferedReader sc) throws java.lang.Exception
	  {
		  ArrayList<Float> res=new ArrayList<>();
		  
		  String s=sc.readLine();
		  String[] ss=s.split(" ");
		
		  for(int i=0;i<ss.length;i++)
		  {
			//  String ss=sc.readLine();
		    	float a=Float.valueOf(ss[i]);
		    	res.add(a);
		  }
	  
		  return res;
	  }
	  ArrayList<Long> getlist(BufferedReader sc) throws java.lang.Exception
	  {
		  ArrayList<Long> res=new ArrayList<>();
		  
		  String s=sc.readLine();
		  String[] ss=s.split(" ");
		
		  for(int i=0;i<ss.length;i++)
		  {
			//  String ss=sc.readLine();
		    	long a=Integer.valueOf(ss[i]);
		    	res.add(a);
		  }
	  
		  return res;
	  }
	  ArrayList<Character> getlistchar(BufferedReader sc) throws java.lang.Exception
	  {
		  ArrayList<Character> res=new ArrayList<>();
		  
		  String s=sc.readLine();
		//  String[] ss=s.split(" ");
		
		  for(int i=0;i<s.length();i++)
		  {
			//  String ss=sc.readLine();
		    	//char[] a=ss[i].toCharArray();
		    	res.add(s.charAt(i));
		  }
	  
		  return res;
	  }

	  static int n;
	  static int b[];
	  static StringBuffer ans = new StringBuffer("");
	  static BufferedReader bf;
	  static class Pair{
	      char val;int cnt;
	      Pair(char val,int cnt)
	      {
	          this.val=val;
	          this.cnt=cnt;
	      }
	  }

	 
	    public static void main(String[] args) throws Exception 
	    {
	    	Main pra=new Main();
	    	//Scanner sc = new Scanner(System.in);
	      //  int tc;
	    	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    //	Scanner in=new Scanner(System.in);
		    long t=Long.parseLong(br.readLine());
		    
		    long res=t+(t*t)+(t*t*t);
		    System.out.println(res);
		//  long max=Long.MAX_VALUE;
		/*   while(t-->0){
		    	//int num=Integer.parseInt(br.readLine());
		   ArrayList<Character> li=pra.getlistchar(br);
		   ArrayList<Character> li2=pra.getlistchar(br);
		 int res=0;
		   for(int i=0;i<li2.size();i++)
		   {
			   if(li.contains(li2.get(i)))
				   res++;
		   }
		   
		   System.out.println(res);
		  
	       }*/
		  // 
	     
	        
	        }
	    }
	   
	    	
	    	
	    	



Measured memory_bytes: 32436
#include<stdio.h>
int main(){
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int x[5][4][11];
for(j=1;j<=4;j++){
	for(k=1;k<=3;k++){
		for(l=1;l<=10;l++){
			x[j][k][l]=0;
		}
	}
}
scanf("%d",&b);
for(a=1;a<=b;a++){
	scanf("%d %d %d %d",&c,&d,&e,&f);
	x[c][d][e]=x[c][d][e]+f;
	c=0;
	d=0;
	e=0;
	f=0;
}
for(i=1;i<=4;i++){
	for(h=1;h<=3;h++){	
		for(g=1;g<=10;g++){
			printf(" %d",x[i][h][g]);
		}
		printf("\n");
	}
	if(i<4) printf("####################\n");
}
return 0;
}


Measured memory_bytes: 2080
#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=998244353;

int32_t main(){
	int n;
	cin>>n;
	int w[n];
	int sum=0;
	int res=0;
	for(int i=0;i<n;i++){
		cin>>w[i];
		sum+=w[i];
	}
	res=w[0];
	int ans=1e18;
	for(int i=1;i<n;i++){
		ans=min(ans,abs(sum-2*res));
		res+=w[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DEBUG
// #define TIME
/*
Learn : -
Problem Type : -
Source : -
*/
#pragma GCC optimize ("Ofast")
#define sint(a) int a; qread(a);
#define sint2(a,b) int a,b; qread(a),qread(b);
#define sint3(a,b,c) int a,b,c; qread(a),qread(b),qread(c);
#define int1(a) qread(a);
#define int2(a,b) qread(a),qread(b);
#define int3(a,b,c) qread(a),qread(b),qread(c);
#define mkp make_pair
#define mkt make_tuple
#define pb emplace_back
#define inf INT_MAX
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sdouble(a) double a; scanf("%lf",&a);
#define slong(a) long long a; scanf("%lld",&a);
#define cstring(a,x) char a[x]; scanf("%s",a);
#define sstring(a) string a;cin>>a;
#define rev(s) reverse(all(s));
#define FOR(a,b,c) for(int a=b;a<c;a++)
#define ROF(a,b,c) for(int a=b;a>c;a--)
#define pause system("pause")
#define endl printf("\n")
#define fastio {ios::sync_with_stdio(false);cin.tie(NULL);}
#define null NULL
#ifdef DEBUG
#define debug(x) cout<< #x << " = " << x;endl;
#else
#define debug(x)
#endif
#define OPEN freopen("input.txt","r",stdin)
#define SEND freopen("output.txt","w",stdout)
#ifdef COM
#define IN(x)
#define OUT(x)
#else
#define IN(x) freopen(x,"r",stdin);
#define OUT(x) freopen(x,"w",stdout);
#endif
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
void qread(int &x){
	int neg=1;x=0;
	register char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}
void Wl(int x)
{
    printf("%d\n",x);
}
void Wl(double x)
{
    printf("%lf\n",x);
}
void Wl(string x)
{
    printf("%s\n",x.c_str());
}
void Wl(ll x)
{
    printf("%lld\n",x);
}
void W(int x)
{
    printf("%d ",x);
}
void W(double x)
{
    printf("%lf ",x);
}
void W(string x)
{
    printf("%s ",x.c_str());
}
void W(ll x)
{
    printf("%lld ",x);
}

int main()
{
    sint(n);
	sstring(s);
	sstring(t);
	int ans=2*n;
	for(int i=1;i<=n;i++)
	{
		bool ok=true;
		FOR(j,0,i)
		{
			if(s[n-i+j]!=t[j])ok=false;
		}
		if(ok)
		{
			ans = 2*n - i;
		}
	}
	Wl(ans);
}
/*

*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	long long int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2*n-1) {
		cout << "No" << endl;
	} else if (x == n){
		cout << "Yes" << endl;
		for (int i = 0; i < 2*n-1; i++) {
			cout << i+1 << endl;
		}
	} else if (x < n) {
		cout << "Yes" << endl;
		for (int i = 1; i <= x-2; i++) {
			cout << i << endl;
		}
		for (int i = n; i > x-2; i--) {
			cout << i << endl;
		}
		for (int i = n+1; i <= 2*n-1; i++) {
			cout << i << endl;
		}
	} else {
		cout << "Yes" << endl;
		for (int i = 1; i < n; i++) {
			cout << i << endl;
		}
		for (int i = x+1; i >= n; i--) {
			cout << i << endl;
		}
		for (int i = 2*n-1; i > x+1; i--) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define MAXN 2005
#define reg register
#define inl inline
using namespace std;
int n,m,q,a[MAXN][MAXN],sum[MAXN][MAXN],sumr[MAXN][MAXN],sumc[MAXN][MAXN];
char ch[MAXN];
int main()
{
	scanf("%d %d %d",&n,&m,&q);
	for(reg int i=1;i<=n;i++)
	{
		scanf("%s",ch+1);
		for(reg int j=1;j<=m;j++) a[i][j]=(ch[j]=='1');
	}
	for(reg int i=1;i<=n;i++)
	{
		for(reg int j=1;j<=m;j++)
		{
			sum[i][j]=a[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			sumr[i][j]=sumr[i-1][j]+sumr[i][j-1]-sumr[i-1][j-1]+(a[i][j] && a[i][j+1]);
			sumc[i][j]=sumc[i-1][j]+sumc[i][j-1]-sumc[i-1][j-1]+(a[i][j] && a[i+1][j]);
		}
	}
	while(q--)
	{
		reg int lx,ly,rx,ry;
		scanf("%d %d %d %d",&lx,&ly,&rx,&ry);
		reg int x=sum[rx][ry]-sum[lx-1][ry]-sum[rx][ly-1]+sum[lx-1][ly-1],y=sumr[rx][ry-1]-sumr[rx][ly-1]-sumr[lx-1][ry-1]+sumr[lx-1][ly-1]+sumc[rx-1][ry]-sumc[rx-1][ly-1]-sumc[lx-1][ry]+sumc[lx-1][ly-1];
		printf("%d\n",x-y);
	}
	return 0;
}

Measured memory_bytes: 64640
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;

     cin>>str;

     for(auto x : str)
     {
         sum+=x-'0';

         sum%=9;
     }

     if(sum)cout<<"No"<<endl;

     else cout<<"Yes"<<endl;



}



Measured memory_bytes: 3748
n,m = list(map(int,input().split()))
ans = 0

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

for i in range(1,m+1):
    flag = True
    for a in alist:
        if i in a:
            continue
        else:
            flag = False
            break
    if flag:
        ans +=1
        
print(ans)


Measured memory_bytes: 3060
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
k = int(input())
#n, k = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

if k >= len(s):
    print(s)
else:
    for i in range(k):
        print(s[i], end="")
    print("...")
        


Measured memory_bytes: 9560
N, x = map(int, input().split())
a_s = map(int, input().split())
sorted_a_s = sorted(a_s)
rest_snaks = x
satisfied_num = 0
for n in range(N):
    if sorted_a_s[n] <= rest_snaks:
        if n == (N-1):
            rest_snaks -= sorted_a_s[n]
            if rest_snaks == 0:
                satisfied_num += 1
        else:
            satisfied_num += 1
        rest_snaks -= sorted_a_s[n]
    else:
        rest_snaks = 0

print(satisfied_num)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int max,min,sum,ans,n;
	int s[101];

	while(1){
		//ÏÌú»
		max = 0;
		min = 1001;
		sum = 0;
		
		//f[^ZbgnÌüÍ
		cin >> n;
		if(n==0) break;//0 0ªüÍ³ê½çI¹

		//f[^ZbgÌ¾¯_ðüÍ
		for(int i=0 ; i<n ; i++){
			cin >> s[i];
		}
		//ÅålAÅ¬lÌlðÛ·é
		for(int i=0 ; i<n ; i++){
			if(max<s[i]) max = s[i];
			if(min>s[i]) min = s[i];
		}
		//ÅåÌ_ðÐÆÂr·é(0ðüêé)
		for(int i=0 ; i<n ; i++){
			if(max==s[i]){
				s[i]=0;
				break;
			}
		}
		//Å¬Ì_ðÐÆÂr·é(0ðüêé)
		for(int i=0 ; i<n ; i++){
			if(min==s[i]){
				s[i]=0;
				break;
			}
		}
		//_Ìvðßé
		for(int i=0 ; i<n ; i++){
			sum += s[i];
		}
		//_Ìv©ç½Ïðßé
		ans = sum/(n-2);
		//¦ÌoÍ
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC opimize (3, "Ofast", "inline")
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int k, q;
const int maxk = 5005;
int d[maxk], dd[maxk];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> k >> q;
	for(int i = 0; i < k; ++i) cin >> dd[i];
	int n, x, m;
	while(q--) {
		cin >> n >> x >> m;
		ll sum = 0;
		for(int i = 0; i < k; ++i) {
			d[i] = dd[i] % m == 0 ? m : dd[i] % m;
			sum += d[i];
		}
		ll ans = x + sum * ((n - 1) / k);
		for(int i = 0; i < (n - 1) % k; ++i) ans += d[i];
		cout << n - 1 - (ans / m - x / m) << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

ll sum(string s){
    ll ans = 0; ll tmp = 0;
    rep(i,s.size()){
        if(tmp == 0)tmp += s[i]-'0';
        else if(s[i] == '+'){ans += tmp; tmp = 0;}
        else {tmp *= 10; tmp += s[i]-'0';}
    }
    ans += tmp; return ans;
}

int main(){
    string s; cin>>s;
    ll ans = 0;
    for(int bit = 0; bit < (1<<s.size()-1); ++bit){
        string t = s; int ad = 1;
        for(int i = 0; i<s.size()-1; ++i){
            if(bit & (1<<i)){t.insert(i+ad,"+"); ++ad;}
        }
        ans += sum(t);
    }
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M,P; cin>>N>>M>>P;
  vector<vector<pii>> A(N);
  vii B(N);
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    A[X-1].pb(mp(Y-1,Z-P));
    B[Y-1].pb(X-1);
  }
  queue<int> q;
  q.push(N-1);
  vector<bool> F(N);
  F[N-1]=1;
  while(q.size()>0){
    int X=q.front(); q.pop();
    rep(i,0,B[X].size()){
      int Y=B[X][i];
      if(!F[Y]){
        F[Y]=1;
        q.push(Y);
      }
    }
  }
  priority_queue<pii> Q;
  Q.push(mp(0,0));
  vi C(N),G(N,-INF);
  G[0]=0;
  while(Q.size()>0){
    int X=Q.top().second,Y=Q.top().first; Q.pop();
    if(G[X]>Y) continue;
    if(C[X]>M){
      cout<<-1<<endl;
      return 0;
    }
    rep(i,0,A[X].size()){
      int P=A[X][i].first,R=Y+A[X][i].second;
      if(F[P]&&G[P]<R){
        G[P]=R;
        Q.push(mp(R,P));
        C[P]++;
      }
    }
  }
  cout<<max(0ll,G[N-1])<<endl;
  }



Measured memory_bytes: 66272
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a > b {
		a, b = b, a
	}
	if b > c {
		b, c = c, b
	}

	if a > b {
		a, b = b, a
	}

	fmt.Println(a, b, c)
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    string c1, c2;
    cin >> c1 >> c2;
    if(c1[0]==c2[2] && c1[2]==c2[0] && c1[1]==c2[1]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int a, b; cin >> a >> b;
  char ans[100][100];
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 50; ++j) {
      ans[i][j] = '.';
    }
    for (int j = 50; j < 100; ++j) {
      ans[i][j] = '#';
    }
  }

  a--; b--;
  while (a > 0) {
    for (int i = 0; i < 100; i += 2) {
      for (int j = 51; j < 100; ++j) {
        if (i % 2 == 0 && j & 1 && ans[i][j] == '#') {
          ans[i][j] = '.';
          i = j = 100;
        }
      }
    }
    --a;
  }

  while (b > 0) {
    for (int i = 0; i < 100; i += 2) {
      for (int j = 0; j < 49; ++j) {
        if (i % 2 == 0 && j % 2 == 0 && ans[i][j] == '.') {
          ans[i][j] = '#';
          i = j = 100;
        }
      }
    }
    --b;
  }

  cout << 100 << " " << 100 << '\n';

  rep(i, 100) {
    rep(j, 100) {
      cout << ans[i][j];
    }
    cout << '\n';
  }

  return 0;
}

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

const int N = 1e5 + 10;

int n, m;
int pr[N], a[N];

int root(int x) {
  return (pr[x] == x ? x : pr[x] = root(pr[x]));
}

void merge(int x, int y) {
  x = root(x);
  y = root(y);
  if (x != y)
    pr[x] = y;
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    --a[i];
  }
  iota(pr, pr + n, 0);
  while (m--) {
    int u, v;
    scanf("%d %d", &u, &v);
    merge(a[u - 1], a[v - 1]);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (root(i) == root(a[i]))
      ++ans;
  printf("%d\n", ans);
  return 0;
}

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

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

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

int main(){

    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n;
    cin >> n;
    vint h(n);
    rep(i, n){
        cin >> h[i];
    }

    vint cost(n, 0);
    cost[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; i++){
        int d1, d2;
        d1 = abs(h[i] - h[i - 1]) + cost[i - 1];
        d2 = abs(h[i] - h[i - 2]) + cost[i - 2];
        // cout << d1 << endl;
        // cout << d2 << endl;
        cost[i] = min(d1, d2);
    }
    // for(auto x : cost) cout << x << endl;

    cout << cost.back() << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S  = keyboard.next();
		
		String X1 = S.replace('A', '#');
		String X2 = X1.replace('T', '#');
		String X3 = X2.replace('G', '#');
		String X4 = X3.replace('C', '#');
		String[] Y = X4.split("");
		
		int count = 0;
		int ans = 0;
		
		for(int i = 0; i<S.length(); i++){
			if(Y[i].equals("#")){
				count++;
				ans = (count > ans) ? count : ans;
				if(count == S.length()){
					ans = count;
					}
			}else{
				ans = (count > ans) ? count : ans;
				count = 0;
					}
			}

		System.out.println(ans);
		keyboard.close();	
	}
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//i番目の子までにアメをj個配るときが何通りあるか
ll dp[110][100010];
const ll MOD = (ll)(1e9 + 7);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,K;
    cin >> n >> K;
    VLL a(n);
    rep(i,n) cin >> a[i];

    dp[0][0] = 1;
    //TLE DP
    /*
    rep(i,n){
        rep(j,K+1){
            //ここがボトルネック
            //遷移先でやっていることは、x = [max(0,j-a[i]),j] までの和を計算している
            //先にDPのiの状態の累積和を取っておくと計算量が縮みそう
            rep(k,a[i]+1){
                if(j-k >= 0){
                    dp[i+1][j] = (dp[i+1][j] + dp[i][j-k]) % MOD;
                }
            }
        }
    }
    */
    ll sumArray[K+1];

    rep(i,n){
        sumArray[0] = dp[i][0];
        FOR(j,1,K+1){
            sumArray[j] = (dp[i][j] + sumArray[j-1])%MOD;
        }
        rep(j,K+1){
            if(j-a[i] <= 0) dp[i+1][j] = sumArray[j];
            else            dp[i+1][j] = (sumArray[j] - sumArray[j-a[i]-1] + MOD) % MOD;
        }
    }

    
    cout << dp[n][K] << endl;
    return 0;
}


Measured memory_bytes: 80128
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)

def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    #print(inv, q, gcd_val)
    return inv % m

def m(n,r):
    d=1
    e=1
    f=1
    for i in range(r):
        d=(n-i)
        e=(i+1)
        d%=(10**9+7)
        f = f*d*modinv(e,(10**9+7))%(10**9+7)
        
    return(f)

n=[int(i) for i in input().split()]
a=sum(n)
if a%3 != 0:print(0)

else:
    b=int(a/3)
    if b==1:
        print(1)
    else:
        c=n[0]-b
        d=n[1]-b
        if c<0 or d<0: print(0)

        else:
            if c==d:
                c=int(b/2)
            d=m(b,min(c,d))
            print(d%(10**9+7))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

int n, k;
vector<int> w;

bool f(int p) {
	dump(p);
	int tmpw = 0;
	int tmpk = 1;
	rep(i, 0, n) {
		if (tmpw + w[i] > p) {
			tmpk++;
			tmpw = w[i];
		}
		else {
			tmpw += w[i];
		}
		dump(tmpw, tmpk, w[i]);
	}
	if (tmpk <= k)return true;
	return false;
}

template<class F>
int binary_search_(int l, int r, F f) {
	if (f(l))return l; // f(l):true
	while (l + 1 < r) {
		int m = (l + r) / 2;
		if (f(m))
			r = m;
		else
			l = m;
	}
	// f(l):false, f(r):true
	return r;
}

signed main() {
	cin >> n >> k;
	w.resize(n); rep(i, 0, n) { cin >> w[i]; }
	cout << binary_search_(*max_element(all(w)), INF, f) << endl;
	return 0;
}

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

struct Prefecture {
    int y, p, i;
    bool operator<( const Prefecture& right ) const {
        return y < right.y;
    }
};

struct Addr {
    int i;
    long addr;
    bool operator<( const Addr& right ) const {
        return i < right.i;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    Prefecture pres[m];
    for (int i = 0; i < m; i++) {
        int p, y;
        cin >> p >> y;
        pres[i] = Prefecture{y, p, i};
    }
    sort(pres, pres+m);
    int prev_y = 0;
    unordered_map<int, int> mp;
    Addr a[m];
    for (int i = 0; i < m; i++) {
        Prefecture pre = pres[i];
        a[i] = Addr{pre.i, ((long) pre.p) * 1000000 + ++mp[pre.p]};
    }
    sort(a, a+m);
    for (auto b: a) {
        cout << setfill('0') << setw(12) << b.addr << endl;
    }
    return 0;
}


Measured memory_bytes: 8356
#include  <bits/stdc++.h>
using namespace std;
long long sum(long long n)
{return n*(n+1)/2;}
 int main(){
 int n;
 cin>>n;
 long long ans;
 ans=sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15;
 cout<<ans;
return 0;
 }


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    ll N;
    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> v;
    for(ll i = 1; i * i <= N; i++) {
        if (N % i == 0) v.push_back(i);
    }

    ll ans = 0;
    for(auto& e : v) {
        ll f = N / e - 1;
        if(N % f == N / f) {
            ans += f;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <float.h>
using namespace std;
struct Point
{
	Point() :x(0.0), y(0.0) {}
	Point(double _x, double _y) : x(_x), y(_y) {}
	double x;
	double y;
};
bool HalfPlaneTest(const Point& P1, const Point& P2, const Point& P)
{
	return ((P2.y - P1.y) * P.x - (P2.x - P1.x) * P.y + (P2.x * P1.y - P1.x * P2.y)) > 0;
}
struct Triangle
{
	Triangle() : minX(DBL_MAX), maxX(DBL_MIN), minY(DBL_MAX), maxY(DBL_MIN) {}
	void add(double x, double y) {
		vP.push_back(Point(x, y));
		if (x < minX) minX = x;
		if (x > maxX) maxX = x;
		if (y < minY) minY = y;
		if (y > maxY) maxY = y;
		if (vP.size() == 3){
			if (HalfPlaneTest(vP[0], vP[1], vP[2]))
				swap(vP[1], vP[2]);
		}
	}
	bool IsInclude(double x, double y){
		if (x <= minX || x >= maxX || y <= minY || y >= maxY)
			return false;
		Point p(x, y);
		if (HalfPlaneTest(vP[0], vP[1], p)) return false;
		if (HalfPlaneTest(vP[1], vP[2], p)) return false;
		if (HalfPlaneTest(vP[2], vP[0], p)) return false;
		return true;
	}
	vector<Point> vP;
	double minX;
	double maxX;
	double minY;
	double maxY;
};

int main()
{
	double x1, y1, x2, y2, x3, y3, x, y;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y){
		Triangle triangle;
		triangle.add(x1, y1);
		triangle.add(x2, y2);
		triangle.add(x3, y3);
		if (triangle.IsInclude(x, y))	cout << "YES\n";
		else							cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 1192
K = int(input())

A = [0]*1000001
A[0] = 7%K
ans = -1

for i in range(1,1000001):
    A[i] = (A[i-1]*10+7)%K

for i in range(1000001):
    if A[i]==0:
        ans = i+1
        break
        
print(ans)

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint fact[200010], inv[200010];

lint comb(lint n, lint r){
    return fact[n] * ((inv[r] * inv[n-r]) % MOD) % MOD;
}

lint power(lint x, lint n){

    lint res = 1;

    while(n > 0){
        if(n & 1){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }

    return res;

}

int main(){

    lint h, w, a, b;
    cin >> h >> w >> a >> b;

    fact[0] = 1;
    inv[0] = 1;
    REP(i, 1, h+w){
        fact[i] = (i * fact[i-1]) % MOD;
        inv[i] = power(fact[i], MOD-2);
    }

    lint ans = 0;

    REP(i, b, w){
        ans += comb(h-a-1+i, i) * comb(a-1+w-i-1, a-1);
        ans %= MOD;
    }

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pll pair <long long,long long>
#define f first
#define s second
#define ll long long
using namespace std;
ll d[101][100001];
int main () {
	ios;
	ll n,m;
	cin>>n>>m;
	pll a[n+1];
	for (ll k=1;k<=n;k++)  {
		cin>>a[k].f>>a[k].s;
	}
	for (int k=1;k<=n;k++)
		fill(d[k]+1,d[k]+100001,1e18);
	
	d[1][a[1].s]=a[1].f;
	
	for (int k=2;k<=n;k++) {
		for (int j=1;j<=100000;j++) {
			d[k][j]=d[k-1][j];
			if (j-a[k].s>=0&&m-d[k-1][j-a[k].s]-a[k].f>=0) d[k][j]=min(d[k][j],d[k-1][j-a[k].s]+a[k].f);
		}
	}
	
	/*for(int i=1;i<=n;i++){
		cout << endl;
		for(int j=1;j<=150;j++){
			cout << d[i][j] << ' ';
		}
	}*/
	for (ll k=100000;k>=1;k--)  {
			if (d[n][k]!=1e18) {
			cout<<k;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;

int main(){
    int a, b, x;
    scanf("%d%d%d", &a, &b, &x);
    printf("%d\n",min(min(a*(x/1000+(x%1000>0)),b*(x/500+(x%500>0))),a*(x/1000)+b*(((x%1000)+499)/500)));
    return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << 1 << endl;
        return 0;
    }
    if (a == b || b == c || a == c) {
        cout << 2 << endl;
        return 0;
    }
    cout << 3 << endl;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

void solve() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if((x-r)>=0&&(x+r)<=W&&(y-r)>=0&&(y+r)<=H)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool check(string s){
	if(s[0] != 'A') return false;
	if(isupper(s[1])) return false;
	
	int cnt = 0;
	for(int i = 2; i < s.size()-1; i++){
		char c = s[i];
		if(c == 'C') {
			cnt++;
			if(cnt >= 2) return false;
		}else if(isupper(c)){
			return false;
		}
	}

	if(isupper(s[s.size()-1])) return false;
	if(cnt == 1) return true;
	return false;
}

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

	string s;
	cin >> s;

	if(check(s)){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b,c,d = map(int, input().split())

top = min(b,d)
down = max(a,c)

print(max(0, top-down))


Measured memory_bytes: 9008
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    int N;cin>>N;
    cout<<(N+1)/2<<endl;
    return 0;
}

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

def down_count():
    count = x[0]
    for i in range(N):
        count += y[i]
    return count

x_list = []

def switch_count():
    for i in range(N - 1):
        sums = x_list[i] + x[i + 1] - y[i]
        x_list.append(sums)

down_sum = down_count()
x_list.append(down_sum)
switch_count()
x_list.sort(reverse=True)
print(x_list[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    int dp[n+1];
    dp[n] = 0;
    int sum = 0, p = 1;
    for(int i = n - 1;i>=0;i--){
    	int num = s[i] - '0';
    	sum += p * num;
    	sum %= 2019;
    	dp[i] = sum;
    	p *= 10;
    	p %= 2019;
    }
    sort(dp,dp+n+1);
    ll ans = 0, num = 1;
    for(int i=1;i<=n;i++){
    	if(dp[i] == dp[i-1]) ans+= num ,num++;
    	else num = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<sstream>
#include<string>
#include<map>
#include<cstdlib>
using namespace std;
main(){
  int a,b;
  char c;
  string s;
  map<int,int> m;
  map<int,int>::iterator it;
  while(getline(cin,s),s.size()){
    stringstream ss(s);
    ss>>a>>c>>b;
    m[a]--;
  }
  while(getline(cin,s)){
    stringstream ss(s);
    ss>>a>>c>>b;
    if(m.count(a))m[a]=abs(m[a])+1;
  }
  for(it=m.begin();it!=m.end();it++){
    if(it->second>0)cout<<it->first<<" "<<it->second<<endl;
  }
}

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

int main(){
  int a, b, c;
  long long int ab_x4, c_b_a_2;
  scanf("%d %d %d", &a, &b, &c);
  if(c-b-a < 0){
    printf("No\n");
  }else{
    ab_x4 = (long long int)4*a*b;
    c_b_a_2 = (long long int)(c-b-a)*(c-b-a);
    if(c_b_a_2 - ab_x4 > 0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//cout << setprecision(numeric_limits<long double>::max_digits10)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
    int n; cin >> n;
    if((n) % 4 == 0 || (n - 7 >= 0 && (n - 7) % 4 == 0 ) || (n - 14 >= 0 && (n - 14) % 4 == 0 )||(n - 21 >= 0 && (n - 21) % 4 == 0 )){
        cout << "Yes" << endl; return 0;
    }else{
        cout << "No" << endl; return 0;
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N,X=map(int,input().split())
L=list(map(int,input().split()))

cnt=1
val=0
while True:
    for i in range(N):
        val+=L[i]
        if val<=X:
            cnt+=1
        else:
            break
    break    
print(cnt)

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

int main(){
  
  int a,b,c; cin >> a >> b >> c;
  
  int mx = max({a,b,c});
  
  if(a == mx){
    cout << b + c << endl;
  }
  else if(b == mx){
    cout << c + a << endl;
  }
  else{
    cout << a + b << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten{

using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using P = std::pair<int64_t, int64_t>;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


void solve(){
    IOS;
    string s;
    cin >> s;
    int q;
    cin >> q;
    int fl = 0;
    string fr="",bc="";
    REP(loop,q){
        int t;
        cin >> t;
        if(t==1){
            fl=(fl+1)%2;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if((fl+f)%2==1){
                fr+=c;
            }else{
                bc+=c;
            }
        }
    }
    reverse(all(fr));
    string res = fr+s+bc;
    if(fl){
        reverse(all(res));
    }
    put(res);
}
} // namespace idaten

int main(){
    idaten::solve();
    return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int>cnt(m);
  for(int i=0; i<n; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int a;
      cin >> a;
      cnt[a-1]++;
    }
  }
  int ret=0;
  for(int i=0; i<m; i++){
    if(cnt[i]==n)ret++;
  }
  cout << ret;
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

bool fn(vector<int> v, int x)
{
  set<int> a;
  a.insert(0);
  each (i, v) {
    if (i == 0) continue;
    set<int> b;
    each (j, a) {
      b.insert(j + i);
      b.insert(j - i);
    }
    swap(a, b);
  }
  return a.count(x);
}

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

  string s;
  int x, y;
  while (cin >> s >> x >> y) {
    vector<int> v;
    int cnt = 0;
    each (c, s) {
      if (c == 'T') {
        v.push_back(cnt);
        cnt = 0;
      }
      if (c == 'F') {
        ++cnt;
      }
    }
    v.push_back(cnt);

    vector<int> a;
    vector<int> b;
    for (int i = 1; i < v.size(); ++i) {
      if (i % 2 == 0) a.push_back(v[i]);
      else b.push_back(v[i]);
    }

    bool f = fn(a, x - v.front()) && fn(b, y);
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 640