akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int n,p,son[50]={0},cou=0,count = 0,i,save=0;
	scanf("%d %d",&n, &p);
	while(n != 0 && p != 0){
	for(i = 0;i < n;i++){
	son[i]=0;
	}
	cou = 0;
	while(1){
		if(cou == n)
			cou = 0;
		if(p!=0){
			son[cou]++;
			p--;
		}else{
			p = son[cou];
			son[cou]=0;
		}
		cou++;
		if(p == 0){
			count =0; 
			for(i = 0;i < n;i++){
				if(son[i] != 0){
				count++;
				save = i;
				}
			}
			if(count == 1){
			
				break;
			}
		}
		}
		printf("%d\n",save);
		scanf("%d %d",&n, &p);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int A[13][13];	
int C[13];
int x;
int P[13];
vector<int> v;
void combo(int cost,int n,int m)
{
	if(n!=0)
	{
		combo(cost,n-1,m);
		for(int i=1;i<=m;i++)
		{
			P[i]+=A[n][i];
		}
		combo(cost+C[n],n-1,m);
		for(int i=1;i<=m;i++)
		{
			P[i]-=A[n][i];
		}
	}
	else
	{
		int flag=1;
		for(int i=1;i<=m;i++)
		{
			if(P[i]<x)
			flag=0;
			
		}
		if(flag==1)
		v.push_back(cost);
	}
	
	
}
int main()
{
	int n,m;
	cin>>n>>m>>x;
	
	for(int i=1;i<=n;i++)
	{
		cin>>C[i];
		for(int j=1;j<=m;j++)
		{
			cin>>A[i][j];
		}
	}
	combo(0,n,m);
	sort(v.begin(),v.end());
	if(v.size()!=0)
	cout<<v[0]<<endl;
	else cout<<-1<<endl;
	
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

void Main() {
	vector<string> abc(3);
	cin >> abc;
	vint dat = {0, 1, 2};
	int ans = abc[0].size() + abc[1].size() + abc[2].size();
	do {
		string a = abc[dat[0]], b = abc[dat[1]], c = abc[dat[2]];
		vector<bool> bc(b.size()+1, false);

		vint cab, cac;
		for (int i = 0; i <= a.size(); i++) {
			bool flag = true;
			int j;
			for (j = 0; j < b.size() && i+j < a.size(); j++) {
				flag &= (b[j] == a[i+j] || a[i+j] == '?' || b[j] == '?');
			}
			if (flag) cab.push_back(i);
		}

		for (int i = 0; i <= b.size(); i++) {
			bool flag = true;
			int j;
			for (j = 0; j < c.size() && i+j < b.size(); j++) {
				flag &= (c[j] == b[i+j] || b[i+j] == '?' || c[j] == '?');
			}
			//cout << endl;
			if (flag) bc[i] = true;
		}
		for (int i = 0; i <= a.size() + b.size(); i++) {
			bool flag = true;
			int j;
			for (j = 0; j < c.size() && i+j < a.size(); j++) {
				flag &= (c[j] == a[i+j] || a[i+j] == '?' || c[j] == '?');
			}
			//cout << endl;
			if (flag) cac.push_back(i);
		}
		//cout << el;	

		sort(begin(cab), end(cab));
		sort(begin(cac), end(cac));

		for (int i = 0; i < cab.size(); i++) {
			for (int j = 0; j < cac.size(); j++) {
				if (cab[i] > cac[j]) continue;
				if (cac[j] - cab[i] >= b.size() || bc[cac[j] - cab[i]]) {
					chmin(ans, max({a.size(), cab[i] + b.size(), cac[j] + c.size()}));
				}
			}
		}

		//cout << a << " " << b << " " << c << " " << ans << endl;
	} while (next_permutation(begin(dat), end(dat)));
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<unordered_set>
using namespace std;
const int MAX = 300;
const int INF = 999999999;

long long solve(int N, int graph[MAX][MAX]) {

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (graph[j][k] > graph[j][i] + graph[i][k])return -1;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (i == j || i == k)continue;
				if (graph[j][k] == graph[j][i] + graph[i][k])graph[j][k] = INF;
			}
		}
	}

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (graph[i][j] != INF)ans += graph[i][j];
		}
	}

	return ans;
}

int main() {
	int N;
	int graph[MAX][MAX];

	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> graph[i][j];
		}
	}

	cout << solve(N, graph) << endl;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			Console.WriteLine(Math.Max(cin.ReadInt() * cin.ReadInt(), cin.ReadInt() * cin.ReadInt()));
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
    int x,ans=1;
    cin>>x;
    for(int i=2;i<=sqrt(x);i++){
        for(int j=i;j<=x;j*=i){
            ans=max(ans, j);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php
$input = explode(" ",trim(fgets(STDIN)));
$a = intval($input[0]);
$b = intval($input[1]);
$c = intval($input[2]);
$cnt = 0;
for($i=$a;$i<=$b;$i++){
    if($c%$i===0){
        $cnt++;
    }
}
echo $cnt;
?>

Measured memory_bytes: 15376
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,R; cin >> N >> R;
  if(N >= 10) cout << R << endl;
  else cout << R + 100*(10-N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a) for (int i = 0; i < a; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define REPR(i, a, b) for (int i = a; i >= b; i--)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, K;
int a[110];
int win[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  rep(i, N) cin >> a[i];
  win[0] = 0;
  REP(i, 1, K+1) {
    int flag = 0, can = 0;
    rep(j, N) {
      int tmp = i-a[j];
      if (tmp >= 0) {
        if (!win[tmp]) can = 1;
      }
    }
    win[i] = can;
  }
  cout << (win[K] ? "First" : "Second") << endl;

  return 0;
}

Measured memory_bytes: 1024
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int mod2 = 998244353;
  const int N = 20005;
  const int INF = 1e16;
  const double PI = acos(-1);

int32_t main()
{
       

    IOS



    int l,r;
    cin >> l >> r;

    if(r - l  > 2019)
    {
      cout << 0;
      return 0;
    }

    int ans = 1e9;

    for(int i = l; i <= r; i++)
    {
      for(int j = i + 1; j <= r; j++)
      {
        ans = min(ans, (i*j)%2019);
        if(ans == 0)
        {
          cout << 0;
          return 0;
        }
      }
    }

    cout << ans;

  return 0;
} 

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

public class Main {
	public void solve() throws IOException {
		int a = nextInt();
		int b = nextInt();
		double x = 3.305785;
		writer.println(a*b/x);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
}

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

int main(){
  int s, n, m, g, h;
  cin >> n >> m;
  int t[m][2];
  int p[n];
  for(int i = 0; i < m; i++){
    cin >> t[i][0] >> t[i][1];
    t[i][0]--;}
  for(int i = 0; i < m; i++){
    for(int j = i + 1; j < m; j++){
      if(t[i][0] == t[j][0]){
        if(t[i][1] != t[j][1]){
          cout << "-1" << endl;
          return 0;
        }
      }
    }
    if(n != 1 && t[i][0] == 0 && t[i][1] == 0){
      cout << "-1" << endl;
      return 0;
    }
  }
int e = 10;
  if(n == 1)
    s = 0;
  if(n == 2)
    s = 10;
  if(n == 3)
    s = 100;
  for(int i = s;  i < max(10 * s,e); i++){
    h = i;
    g = 1;
    for(int j = 0; j < n; j++){
      p[n - j - 1] = h % 10;
      h = h / 10;
    }
    for(int k = 0; k < m; k++){
      for(int j = 0; j < n; j++){
        if(t[k][0] == j){
          if(t[k][1] != p[j])
            g = 0;
        }
      }
    }
    if(g){
      cout << i << endl;
      return 0;
    }
    else if(h == 10 * s - 1)
      cout << "-1" << endl;
  }
}


Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
temp_min = A[0]
max_diff = 0
for i in range(1, N):
    if A[i] < temp_min:
        temp_min = A[i]
    else:
        diff = A[i] - temp_min
        if diff > max_diff:
            ans = 1
            max_diff = diff
        elif diff == max_diff:
            ans += 1
print(ans)


Measured memory_bytes: 14252
from functools import cmp_to_key
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
mp = {}
for i in range(M):
    b,c = map(int,input().split())
    if c in mp:
        mp.update({c:b+mp[c]})
    else:
        mp.update({c:b})
for i in A:
    if i in mp:
        mp.update({i:1+mp[i]})
    else:
        mp.update({i:1})
lis = list(reversed(sorted(mp.items(), key=lambda x: x[0])))
res = 0
item = 0
for i in lis:
    if item + i[1] <= N:
        item = item + i[1]
        res = res + i[1]*i[0]
    else:
        res = res + (N-item)*i[0]
        break
print(res)

Measured memory_bytes: 43536
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,n,t;
  cin>>h>>n;
  int arr[n+10];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
 for(int i=0;i<n; i++)
 {
     h-=arr[i];
 }
 if(h<=0)
 {
     cout<<"Yes"<<endl;
 }
 else
 {
 cout<<"No"<<endl;
}
}


Measured memory_bytes: 640
#include<stdio.h>
#define LEN 5000000
 
int H,A[LEN];
 
void maxHeapfy(int );
 
int main(){
  int i;
  scanf("%d",&H);
 
  for( i = 1 ; i <= H ; i++ )
    scanf("%d",&A[i]);
  for( i = H/2 ; i >= 1 ; i-- )
    maxHeapfy(i); 
  for( i = 1 ; i <= H ; i++)
    printf(" %d",A[i]);

  puts("");
 
  return 0;
 
}
void maxHeapfy(int i){
 
  int  l,r,largest,t;
  l = 2 * i;
  r = 2 * i +1;
 
  if( l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;
 
  if( largest != i){
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapfy(largest);
  }
 
}
 



Measured memory_bytes: 3652
def examB():
    St = S()
    d = ""
    ans = "yes"
    for s in St:
        if s in d:
            ans = "no"
        d += s
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38256
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926

struct node
{
    int a, b;
} p[500000];
int ct=0;
int ans=0;
int n, m;
int pre[500000];
int find(int x)
{
    if (pre[x] != x)
        return pre[x] = find(pre[x]);
    return x;
}
void intt()
{
    for (int i = 1; i <= n; i++)
        pre[i] = i;
}
int check(int x)
{
    int res = 0;
    for (int i = 1; i <= m; i++)
    {
        if (i == x)
            continue;
        if (find(p[i].a) != find(p[i].b))
        {
            pre[find(p[i].a)] = find(p[i].b);
            res++;
        }
        if (res == n - 1)
            break;
    }
    // cout << res << endl;
    if (res == n - 1)
        return 0;
    return 1;
}
int main()
{

    cin >> n >> m;
    // while (m--)
    for (int i = 1; i <= m; i++)
        cin >> p[i].a >> p[i].b;
    for (int i = 1; i <= m; i++)
    {
        intt();
        if (check(i))
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
	long double a;
	long double b;
	cin >> a>> b;
	ll ans=(ll)floor(a*b);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
//By Don4ick 
//#define _GLIBCXX_DEBUG
 
#include <bits/stdc++.h>
 
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
 
#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234
 
const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};
 
const int N = (int)1e5 + 228;
const int LOG = 60;
 
using namespace std;
 
int n, m, up[LOG][N], p[N];
ll d[N], x[N], k, res[N];
 
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		
 
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
 
	//~read
	scanf("%d", &n);
	forn(i, n)
		scanf("%lld", &x[i]);
	forn(i, n - 1)
		d[i] = x[i + 1] - x[i];
	//~solve
	forn(i, n - 1)
		p[i] = i;
	scanf("%d%lld", &m, &k);
	forn(i, m)	
	{
		int id;
		scanf("%d", &id);
		swap(p[id - 1], p[id]);
	}
	//~precalc
	forn(i, n - 1)
		up[0][p[i]] = i;
	for (int i = 1; i < LOG; i++)
	{
		forn(j, n - 1)
		{
			up[i][j] = up[i - 1][up[i - 1][j]];
		}
	}
	forn(i, n - 1)
	{	
		int v = i;
		for (int j = LOG - 1; j >= 0; j--)
		{
			if (k & (1ll << j))
				v = up[j][v];
		}
		res[v] = d[i];
	}                 
	for (int i = 1; i <= n; i++)
	{
		if (i > 1)
			x[i] = x[i - 1] + res[i - 1];
		printf("%lld\n", x[i]);
	}
		
 
	return 0;
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int x,y;
    cin>>S;
    rep(i,0,3)
    {
        if(S[i]=='7')
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;

typedef vector<long long> vec;
typedef vector<vec> mat;

long long MOD = 1000000007;

mat Mul(mat M, mat N) {
	mat R(M.size(), vec(N[0].size(), 0));
	for (int i = 0; i < M.size(); i++) {
		for (int j = 0; j < N[0].size(); j++) {
			for (int k = 0; k < M[0].size(); k++) {
				R[i][j] += (M[i][k] * N[k][j]) % MOD;
				R[i][j] %= MOD;
			}
		}
	}
	return R;
}

mat Calc(mat M, long long N) {
	if (N == 1) return M;
	if (N % 2 == 0) {
		mat R = Calc(M, N / 2);
		return Mul(R, R);
	}
	return Mul(M, Calc(M, N - 1));
}

int main() {
	long long N, K;
	cin >> N >> K;
	mat M(N, vec(N, 0));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) cin >> M[i][j];
	}
	mat R = Calc(M, K);
	long long ANS = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ANS += R[i][j];
			ANS %= MOD;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<vector<int>> dir{ {1,0},{0,1},{-1,0},{0,- 1} };

	bool isEnd = false;
	int cnt = 0;

	queue<vector<int>> que;
	for (int i = 0; i < h;i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				que.push(vector<int>{i, j, 0});
			}
		}
	}

	while (!que.empty()) {
		
		int x = que.front()[0];
		int y = que.front()[1];
		cnt = que.front()[2];
		que.pop();

		for (int k = 0; k < 4;k++) {
			int x1 = dir[k][0] + x;
			int y1 = dir[k][1] + y;
			if (x1< 0 || x1 >= h) {
				continue;
			}
			if (y1 < 0 || y1>= w) {
				continue;
			}

			if (a[x1][y1] == '.') {
				isEnd = false;
				a[x1][y1] = '#';
				que.push(vector<int>{x1, y1, cnt + 1});
			}
		}

	}
	cout << cnt << endl;
}



Measured memory_bytes: 56756
N = int(input())
a_line_map = map(int, input().split(' '))

#sorted_a_map <- a_line_map 降順ソート
sorted_a_map = sorted(a_line_map, reverse=True)
#diff_map <- sorted_a_map 奇数 -1倍
diff_map = (num if i%2==0 else -num for i,num in enumerate(sorted_a_map))
print(sum(diff_map))

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct UnionFind {
    vector< int > data;
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }    
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> p(n); rep (i, n) cin >> p[i];
    UnionFind uf(n);
    rep (_, m) {
        int x, y; cin >> x >> y; x--; y--;
        uf.unite(x, y);
    }
    int ans = 0;
    rep (i, n) if (uf.find(i) == uf.find(p[i] - 1)) ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    long long ans;
    if(k%2==0){
        ans = a-b;
    }else{
        ans = -1*(a-b);
    }
        cout << ans << endl;
}

Measured memory_bytes: 256
a1 = input().split(" ")
a2 = input().split(" ")
a3 = input().split(" ")
a = a1 + a2 + a3
for i in range(9):
	a[i] = int(a[i])
n = int(input())
for i in range(n):
	b = int(input())
	for j in range(9):
		if b == a[j]:
			a[j] = 0
l = []
l.append(a[0]+a[1]+a[2])
l.append(a[3]+a[4]+a[5])
l.append(a[6]+a[7]+a[8])
l.append(a[0]+a[3]+a[6])
l.append(a[1]+a[4]+a[7])
l.append(a[2]+a[5]+a[8])
l.append(a[0]+a[4]+a[8])
l.append(a[2]+a[4]+a[6])
if 0 in l:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
from collections import Counter
n,m = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
for a in A:
    B.append((B[-1]+a)%m)
D = Counter(B)
res = 0
for v in D.values():
    res += v*(v-1)//2
print(res)


Measured memory_bytes: 16556
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::marker::*;
use proconio::*;

#[fastout]
fn main() {
    input! {
        k: i32,
        n: usize,
        a: [i32; n],
    }
    // annotate for rust-analyzer
    let k: i32 = k;
    let n: usize = n;
    let a: Vec<i32> = a;

    let mut mx = 0;
    for i in 0..n {
        let tmp = if i == 0 {
            a[i] + k - a[n - 1]
        } else {
            a[i] - a[i - 1]
        };
        mx = mx.max(tmp);
    }

    println!("{}", k - mx);
}


Measured memory_bytes: 4120
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

void CTravelingSalesmanAroundLake(std::istream& in, std::ostream& out) {
  int k, n;
  vector<int> a;
  in >> k >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    in >> x;
    a.push_back(x);
  }
  int max_dist = (k - a[n - 1]) + a[0];
  for (int i = 1; i < n; ++i) {
    max_dist = max(max_dist, a[i] - a[i - 1]);
  }
  out << k - max_dist << endl;
}

int main(int argc, char** argv) { CTravelingSalesmanAroundLake(cin, cout); return 0; }


Measured memory_bytes: 1400
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int M = sc.nextInt();
    int D = sc.nextInt();

    int count = 0;
    for (int m = 1; m <= M; m++) {
      for (int d = 1; d <= D; d++) {
        int d10 = d / 10;
        int d1 = d % 10;
        if (d10 >= 2 && d1 >= 2 && m == d10 * d1) count++;
      }
    }
    os.println(count);
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

const int MAX_WH = 33;
int H, W, s;
int G[MAX_WH][MAX_WH];
int S[MAX_WH][MAX_WH];
pair<int, int> T[MAX_WH][MAX_WH][MAX_WH][MAX_WH];

int make() {
  for(int h = 0; h <= H; ++h) {
    for(int w = 0; w <= W; ++w) {
      S[h][w] = 0;
      for(int i = 0; i < h; ++i) {
	for(int j = 0; j < w; ++j) {
	  S[h][w] += G[i][j];
	}
      }
    }
  }
}

int sum(int sx, int sy, int ex, int ey) {
  return S[ey][ex] - S[ey][sx] - S[sy][ex] + S[sy][sx];
}

pair<int, int> solve(int sx, int sy, int ex, int ey) {
  pair<int, int> &res = T[sy][sx][ey][ex];
  pair<int, int> p1, p2;
  if(res.first == -1) {
    res.first = 1;
    res.second = -1 * (sum(0,0,W,H) - sum(sx,sy,ex,ey));
    for(int i = sx+1; i < ex; ++i) {
      int d = max(sum(0,0,W,H) - sum(sx, sy, i, ey),
		  sum(0,0,W,H) - sum(i, sy, ex, ey));
      if(d <= s) {
	p1 = solve(sx,sy,i,ey);
	p2 = solve(i,sy,ex,ey);
        res = max(res, make_pair(p1.first+p2.first, min(p1.second, p2.second)));
      }
    }
    for(int i = sy+1; i < ey; ++i) {
      int d = max(sum(0,0,W,H) - sum(sx, sy, ex, i),
		  sum(0,0,W,H) - sum(sx, i, ex, ey));
      if(d <= s) {
	p1 = solve(sx,sy,ex,i);
	p2 = solve(sx,i,ex,ey);
        res = max(res, make_pair(p1.first+p2.first, min(p1.second, p2.second)));
      }
    }
  }
  return res;
}

int main() {
  while(cin >> H >> W >> s && (H || W || s)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> G[i][j];
      }
    }
    make();
    fill(T[0][0][0], T[MAX_WH][0][0], make_pair(-1,-1));
    pair<int, int> ans = solve(0,0,W,H);
    cout << ans.first <<  " " << s+ans.second << endl;
  }
  return 0;
}

Measured memory_bytes: 9000
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#define maxn 300009
using namespace std;
char s[maxn];
int n;
int cnt[30];
set<int>st[40];
int PR[maxn], pos[maxn];
int b[maxn];
vector<pair<int, int> >G;

bool cmp(pair<int,int>x, pair<int,int>y){
	return x.first - x.second < y.first - y.second;
}

void update(int x){
	while(x < maxn){
		b[x] += 1;
		x += x & -x;
	}
}

int getsum(int x){
	int sum = 0;
	while(x > 0){
		sum += b[x];
		x -= x & -x;
	}
	return sum;
}

int main(){
	memset(PR, -1, sizeof(PR));
	scanf("%s", s);
	n = strlen(s);
	for(int i = 0; i < n; i++){
		cnt[s[i] - 'a']++;
	}
	int num  = 0;
	for(int i = 0; i < 26; i++){
		if(cnt[i] & 1)
			num++;
	}
	if(num >= 2){
		puts("-1");
		return 0;
	}
	
	for(int i = 0; i < n; i++){
		st[s[i] - 'a'].insert(i);
	}
	
	long long ans = 0;
	
	for(int i = 0; i < 26; i++){
		while((int)st[i].size() > 1){
			auto it = st[i].begin();
			int head = *it;
			it = st[i].end();
			--it;
			int tail = *it;
			
			G.push_back(make_pair(head, tail));
			
			it = st[i].begin();
			st[i].erase(it);
			it = st[i].end();
			--it;
			st[i].erase(it);
		}
		if((int)st[i].size() == 1){
			auto it = st[i].begin();
			int head = *it;
			pos[head] = n / 2;
		}
	}
	
	int cur = 0;
	int sz = G.size();
	sort(G.begin(), G.end(), cmp);
	
	for(int i = 0; i < sz; i++){
		pos[G[i].first] = cur;
		pos[G[i].second] = n - 1 - cur;
		cur++;
	}
	
	for(int i = n - 1 ; i >= 0; i--){
		ans += getsum(pos[i] + 1);
		update(pos[i] + 1);
	}
		
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 13432
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if(a+b+c>=22)
    {
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static final int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		double[] A = new double[N];
		double[] B = new double[N];
		double[] C = new double[N];
		for (int i = 0; i < A.length; i++) {
			A[i] = in.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = in.nextLong();
		}
		for (int i = 0; i < C.length; i++) {
			C[i] = in.nextLong();
		}
		Arrays.sort(A);
		Arrays.sort(C);
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long underNum = Arrays.binarySearch(A, B[i] - 0.1);
			long overNum = Arrays.binarySearch(C, B[i] + 0.1);
			ans += (-1 - underNum) * (N + overNum + 1);
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 98092
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s;
  cin >> s;

  s[5] = ' ';
  s[13] = ' ';

 cout << s; 


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int p = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int n = 0; n <= c; n++) {
					if(500 * i + 100 * j + 50 * n == x) {
						p++;
					}
				}
			}
		}
		System.out.println(p);
	}
}


Measured memory_bytes: 21844
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))
(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))
(defmacro read-str ()
  `(write-to-string (read)))

;;本体
(defun main()
  (println (ceiling (/ (+ (read) (read)) 2))))

#-swank(main)


Measured memory_bytes: 10728
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    int n;
    cin>>n;
    int a,ans=0;
    set<int> s;
    ifr(i,0,n){
        cin>>a;
        s.insert(a);
        if(*(s.begin())>=a) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i, a, b) for(int i=(int)(a); i>=(int)(b); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

int main(void)
{
    int P, Q, R;
    cin >> P >> Q >> R;
    if(P<=Q and R<=Q){
        cout << P+R << endl;
    }else if(Q<=R and P<=R){
        cout << Q+P << endl;
    }else{
        cout << R+Q << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
    s: Chars,
    }
    let mut s:Vec<_> = s.into_iter().map(|x| x.to_digit(10).unwrap() as usize).collect();
    s.reverse();
    let mut t = 1;
    let mut cnts = vec![0; 2019];
    cnts[0] = 1;
    let mut sum = 0;
    for c in s {
        sum += c * t;
        sum %= 2019;
        t *= 10;
        t %= 2019;
        cnts[sum] += 1;
    }
    let mut ans = 0;
    for cnt in cnts{
        ans += cnt * (cnt - 1) / 2
    }
    println!("{}", ans);
}


Measured memory_bytes: 4648
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll A;cin>>A;
string str;
map<string,ll> data;
REP(i, A){
  cin >> str;
  data[str]++;
}
cout << "AC x " << data["AC"] << endl;
cout << "WA x " << data["WA"] << endl;
cout << "TLE x " << data["TLE"] << endl;
cout << "RE x " << data["RE"] << endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	String [] words = new String[100];
	private Scanner kb;
	public void process() {
		kb = new Scanner(System.in);
		int N = kb.nextInt();
		int K = kb.nextInt();
		String S = kb.next();
		
		for(int i=0; i<N; i++) {
			words[i] = S.substring(i,i+1);
		}
		words[K-1] = words[K-1].toLowerCase();
		for(int i=0; i<N; i++) {
			System.out.print(words[i]);
		}
	}

	public static void main(String [] args) {
		Main app = new Main();
		app.process();
	}
}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  bool res = false;
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++)
      if (i * j == n) res = true;
  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
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<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int a, b;
  cin >> a >> b;
  rep3(x, 1, 10000) {
    int a2 = x * 8 / 100;
    int b2 = x * 10 / 100;
    // cout << x << " " << a2 << " " << a << endl;
    if (a2 == a && b2 == b) {
      cout << x << endl;
      return;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> w(n), v(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    map<P, ll> dp;
    set<ll> se;
    se.insert(0);
    for (ll i = 0; i < n; i++)
    {
        for (auto j : se)
        {
            chmax(dp[P(i + 1, j)], dp[P(i, j)]);
            if (j + w[i] <= m)
            {
                if (!dp[P(i, j + w[i])])
                {
                    se.insert(j + w[i]);
                }
                chmax(dp[P(i + 1, j + w[i])], dp[P(i, j)] + v[i]);
            }
        }
    }
    ll ans = 0;
    for (auto i : se)
    {
        chmax(ans, dp[P(n, i)]);
    }
    cout << ans << endl;
}

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

#define irep(i,n)  for(int i=0;i<(n);i++)
#define irepy(i,n) for(int i=1;i<=(n);i++)
#define jrep(j,n)  for(int j=0;i<(n);j++)
#define jrepy(j,n) for(int j=1;i<=(n);j++)

int main(){

  string s;
  cin >> s;

  string count = "Yes";

  for(int i=0;i< int(s.length());i++){
    if(i%2==0){
      if(s[i]=='L') count= "No";
    }
    
    else{
      if(s[i]=='R') count= "No";
    } 
  }
  cout << count <<endl;
  
  return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int w, h;
string smax(string s, string t) {
	
	if (s.size() < t.size())return t;
	if (t.size() < s.size())return s;
	if (s.size() == 0)return t;
	if (t.size() == 0)return s;

	REP(i, s.size()) {
		if (s[i] < t[i])return t;
		if (s[i] > t[i])return s;
	}
	return s;
}
string dfs(vector<string> &v, vector<vector<string>> &dp, int x, int y) {
	if (x >= w || y >= h)return "";
	if (isalpha(v[y][x]))return "";
	if (dp[y][x] != "")return dp[y][x];
	string ret = "";
	ret += v[y][x];
	string tmp;
	tmp = smax(tmp, dfs(v, dp, x + 1, y));
	tmp = smax(tmp, dfs(v, dp, x, y + 1));
	return dp[y][x] = ret + tmp;
	
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
	
		cin >> w >> h;
		if (!w)break;
		vector<string> v(h);
		vector<vector<string>> dp(h, vector<string>(w, ""));
		REP(i, h)cin >> v[i];
		
		string ans;
		REP(i, h) {
			REP(j, w) {
				if (dp[i][j] == "")dfs(v, dp, j, i);
			}
		}
		REP(i, h) {
			REP(j, w) {
				REP(p, dp[i][j].size()) {
					if (dp[i][j][p] != '0') {
						dp[i][j] = dp[i][j].substr(p);
						break;
					}
					if (p == dp[i][j].size() - 1)dp[i][j] = "0";
				}
				ans = smax(ans, dp[i][j]);
			}
		}
	
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3204